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!  



Php Convert String To Title Case | Php Convert Url To Link | Php Create Simple Form From Db


 

  Tips | Home | Search | Contact

Link here: