Liam Delahunty: Home Tips Web Contact
Recommended laptop
under £500
.

Think I deserve a present? See my Amazon Wish List

Convert URLs into a link

In a comments field, from your log analysis or via your own spidering you may want to turn the urls you get into links. In php you can do the following:


$str = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\">\\0</a>", $str);

There may be occations when you want to add the rel=nofollow attribute to your links to indicate to the search engines that you don't "trust" the link, and don't want to pass any "juice". See Mutt Cutts' page on No Follow

$str = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\" rel=\"nofollow\">\\0</a>", $str);

Share this!