Ver Mensaje Individual
  #3 (permalink)  
Antiguo 19/05/2008, 12:57
Surfiction
 
Fecha de Ingreso: enero-2008
Mensajes: 132
Antigüedad: 16 años, 3 meses
Puntos: 6
Respuesta: Ayuda reconocer una url

Código PHP:
function links($x)
    {
    return 
preg_replace(
        array(
        
'/(?(?=<a[^>]*>.+<\/a>)
        (?:<a[^>]*>.+<\/a>)
        |
        ([^="\']?)((?:https?|ftp|bf2|):\/\/[^<> \n\r]+)
        )/iex'
,
        
'/<a([^>]*)target="?[^"\']+"?/i',
        
'/<a([^>]+)>/i',
        
'/(^|\s)(www.[^<> \n\r]+)/iex',
        
'/(([_A-Za-z0-9-]+)(\\.[_A-Za-z0-9-]+)*@([A-Za-z0-9-]+)
        (\\.[A-Za-z0-9-]+)*)/iex'
        
),
        array(
        
"stripslashes((strlen('\\2')>0?'\\1<a href=\"\\2\">Descargar (Link Externo)</a>\\3':'\\0'))",
        
'<a\\1',
        
'<a\\1 target="_blank" rel="nofollow">',
        
"stripslashes((strlen('\\2')>0?'\\1<a href=\"http://\\2\"  target=\"_blank\" rel=\"nofollow\">Link Externo</a>\\3':'\\0'))",
        
"stripslashes((strlen('\\2')>0?'<a href=\"mailto:\\0\">\\0</a>':'\\0'))"
            
),
    
$x
    
);
    }

echo 
links("http://www.algunlinksaconvertir.com"); 
Esa funcion la uso aqui www.tilichesgratis.com/blog , pasate y mira como funcionan los links(las imagenes se convierten igual no usan bbcode)

Suerte