Ver Mensaje Individual
  #2 (permalink)  
Antiguo 23/10/2013, 08:48
Avatar de jonni09lo
jonni09lo
Colaborador
 
Fecha de Ingreso: septiembre-2011
Ubicación: Estigia
Mensajes: 1.471
Antigüedad: 12 años, 7 meses
Puntos: 397
Respuesta: Links automáticos

Hola, hace mucho tiempo tuve un problema similar y despues de mucho probar, me he quedado con esta funcion. Espero te sirva

Código PHP:
Ver original
  1. function makeLinks($subject) {
  2.     $pattern = "/(?i)\b(((http|https|ftp):\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'\".,<>?«»“”‘’]))/";
  3.        $text = preg_replace($pattern, "<a href=\"http://$1\" target=\"_blank\">$1</a>", $subject);
  4.        $text = str_replace("href=\"www.","href=\"http://www.",$text);
  5.     $text = str_replace("href=\"http://http://","href=\"http://",$text);
  6.     return $text;
  7. }

Saludos
__________________
Haz preguntas inteligentes-Como ser Hacker
No hacer preguntas por mensaje privado. No sólo no es inteligente sino que es egoísta.