caballero Posted September 3, 2010 Share Posted September 3, 2010 Howdy, I'm in trouble here. Does someone know how to wrap a url which is in the string with href tag without writing like a few hundred line long code? Example: Before: "This is a url http://www.domain.com and then some text" After: "This is a url <a href="http://www.domain.com">http://www.domain.com</a> and then some text" the string is to be received by a flash application right after. Quote Link to comment Share on other sites More sharing options...
freelance84 Posted September 3, 2010 Share Posted September 3, 2010 $url = "www.url.com"; $href_url="<a href=\"http://$url\">http://$url</a> Quote Link to comment Share on other sites More sharing options...
ldb358 Posted September 3, 2010 Share Posted September 3, 2010 <?php function replace_links($string){ $start = strpos($string, 'http://'); if($start !== false){ $end = strpos($string, " ",$start); $link = substr($string, $start,$end-$start); $link = "<a href='$link'>".$link."</a>"; return substr_replace($string,$link,$start,$end-$start); }else{ return $string; } } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.