Ver Mensaje Individual
  #3 (permalink)  
Antiguo 10/12/2007, 21:30
Avatar de hgp147
hgp147
 
Fecha de Ingreso: diciembre-2006
Ubicación: Buenos Aires, Argentina
Mensajes: 980
Antigüedad: 17 años, 4 meses
Puntos: 36
Re: Error al converir http:// o www. en links

Hola Lanselot, aun sigue sin funcionar


Código PHP:
<?php
function hyperlink($text) {
    
// match protocol://address/path/file.extension?some=variable&another=asf%

$text preg_replace("/\s([a-zA-Z]+:\/\/[a-z][a-z0-9\_\.\-]*[a-z]{2,6}[a-zA-Z0-9\/\*\-\?\&\%]*)([\s|\.|\,])/i"" <a href=\"$1\">$1</a>$2"$text);
    
// match [url]www.something.domain/path/file.extension?some=variable&another=asf%[/url]

$text preg_replace("/\s(www\.([a-z][a-z0-9_\..-]*[a-z]{2,6})([a-zA-Z0-9\/*?&%-]*))\s/i"" <a href=\"http://$1\">$2</a> "$text);
    
return 
$text;

}
    
$text "www.algo.com";

echo 
hyperlink($text);    
    
?>
Gracias