Hello -- I have a PHP app that pulls text from a DB and renders it to the screen as part of a web page. At present, any URLs in the text are just written to the page; I'd like to be able to dynamically re-write the URLs as HTML links. Any guidance you can offer here is most welcome.
Thanks, Dieter
it you have the html coming out of the db as $html, you can try this:
$html = preg_replace("/\s(f|ht)(tp)(:\/\/|s:\/\/)(\S+)/i", " <a href=\"\\1\\2\\3\\4\">\\1\\2\\3\\4</a>", $html);
That's perfect -- thanks! I noticed that if the URLs in the plain text are followed by commas (such as "http://www.google.com,"), the comma is added to the link. Is there any way to avoid that?
Thanks again, Dieter