Hi all
I'm trying to find any urls inside a paragraph of text pulled from a db and wrap an a tag around it. At the moment I have the following which isn't working.
$content = $row[2];
$urlStart = strstr($content, "http://");
$url_http = substr($urlStart, 0, strpos(array($urlStart), array(" ", "/r/n", "/r", "/n")));
$url_plain = str_replace(array("http://"), array(""), $url_http);
$url_name = substr($url_plain, 0, 40);
if (strlen($url_plain) >= 40)
{
$text = str_replace(array($url_http), array("<a class='diaryUrl' target='_blank' href=".$url_http." >".$url_name."</a>"), $content);
} else {
$text = str_replace(array($url_http), array("<a class='diaryUrl' target='_blank' href=".$url_http." >".$url_plain."</a>"), $content);
}
Any help will be greatly appreciated