
13/02/2008, 13:13
|
| | Fecha de Ingreso: febrero-2007 Ubicación: Valencia
Mensajes: 457
Antigüedad: 18 años Puntos: 0 | |
Re: ¿Como puedo solucionar esto? Enlace cliqueable Cita:
Iniciado por okram Podrías solucionarlo usando la función preg_replace_callback(): Código PHP: function ConvertirCortar( $matches ) {
$limite = 30;
$matches[0] = (strlen($matches[0]) > $limite) ? substr($matches[0],0,15)."...".substr($matches[0],19-$limite) : $matches[0];
return "<a href=\"".(!empty($matches[3]) ? $matches[3] : "http")."://$matches[4]$matches[5]$matches[6]\" target=\"_blank\">$matches[0]</a>";
}
function ponerLinks( $str ) {
return preg_replace_callback("/((([a-zA-Z]+):\/\/)|(www\.))([\w\.]+)([\#\,\/\~\?\&\=\;\%\-\w+\.]+)/i",'ConvertirCortar',$str);
}
echo ponerLinks($str);
Aquí tienes un ejemplo funcionando: EJEMPLO: http://ejemplos.fdw.myokram.info/link/ CÓDIGO: http://ejemplos.fdw.myokram.info/link/?source
Un saludo,  Muchisimas gracias    |