i wrote this code and i was having a problem since
it will convert this:
http://www.ccc.com
to:
<a target="_blank" rel="nofollow" href="http://www.ccc.com">http://www.ccc.com</a>
but if there was already a link:
<a href="http://www.xxx.com">http://www.xxx.com</a>
it will change it like that:
<a href="http://www.xxx.com<a href="http://www.xxx.com">http://www.xxx.com"></a></a>
how can i make my code ignore the links?
Code:function render_links($str){ return ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a target=\"_blank\" rel=\"nofollow\" href=\"/go/\\0\">\\0</a>", $str); }



Reply With Quote

Bookmarks