You can use the following:
$string = "Look on http://www.google.com";
$string = preg_replace(
"~[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]~",
"<a href="\0">\0</a>",
$string);
PHP versions < 5.3 (ereg_replace) otherwise (preg_replace)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…