Como ya te han dicho: con expresiones regulares.
Prueba a hacer una función como:
Código PHP:
function hacer_links($texto) {
$texto = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)',
'<a href="\\1">\\1</a>', $texto);
$texto = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)',
'\\1<a href="http://\\2">\\2</a>', $texto);
$texto = eregi_replace('([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})',
'<a href="mailto:\\1">\\1</a>', $texto);
return $texto;
}
Y ya podrás sacar links del texto que quieras:
Código PHP:
$comentario = "Busca lo que quieras en www.google.com";
echo hacer_links($comentario);
suerte