Where I talk about me, programming and other stuff that you will not read

PHP convert URL into a link

A small code snippet used to convert URLs into HTML live links with PHP.  Useful for when creating a user comments post box.

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

If your using this for a comments section or forum you may want to add the rel=nofollow attribute so the google bot will ignore the link.

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


www.pippo.it writes:
Posted 15 Feb 2012

Post a comment

New user? Thats ok you can still post.

Your name:
Your email:
A password:

Web designer?

Twitter (follow)

I'm rocking out to

All that remains