$mensaje = "Enlace de prueba: http://google.es"; $mensaje = preg_replace("/http\:\/\/(\S+)/i","<a href='http://\\1'>http://\\1</a>", $mensaje); echo $mensaje;