PHP Function: linkify

I needed a function to take a chunk of text and turn all the URLs inside of it to hyperlinks. Here is the solution I came up with:

function linkify($str) {
    $new_str = preg_replace("@[http|https|ftp]+://[^<>[:space:]]+[[:alnum:]/]@","<a href=\"\\0\">\\0</a>", $str);
    return $new_str;
}


Note: Replies will be formatted with PHP Markdown Extra syntax.

Name: Email (Not Required):
 
Logged IP: 18.116.12.7
To prevent spam please submit by clicking the kitten: