Tema: publicar url
Ver Mensaje Individual
  #7 (permalink)  
Antiguo 27/04/2010, 14:36
Avatar de gildus
gildus
 
Fecha de Ingreso: agosto-2003
Mensajes: 1.495
Antigüedad: 20 años, 9 meses
Puntos: 105
Respuesta: publicar url

Haber,

Código PHP:
Ver original
  1. $cadena = "termine el trabajo. http://www.trabajo.com/fin";
  2.  
  3. function clickable($url){
  4.         $url                                    =    str_replace("\\r","\r",$url);
  5.         $url                                    =    str_replace("\\n","\n<BR>",$url);
  6.         $url                                    =    str_replace("\\n\\r","\n\r",$url);
  7.  
  8.         $in=array(
  9.         '`((?:https?|ftp)://\S+[[:alnum:]]/?)`si',
  10.         '`((?<!//)(www\.\S+[[:alnum:]]/?))`si'
  11.         );
  12.         $out=array(
  13.         '<a href="$1"  rel=nofollow>$1</a> ',
  14.         '<a href="http://$1" rel=\'nofollow\'>$1</a>'
  15.         );
  16.         return preg_replace($in,$out,$url);
  17.     }
  18.  
  19. echo clickable($cadena);

http://www.php.net/manual/en/functio...lace.php#85722


Saludos
Gildus
__________________
.: Gildus :.