Ver Mensaje Individual
  #5 (permalink)  
Antiguo 07/03/2011, 17:58
fernandrock
 
Fecha de Ingreso: diciembre-2010
Mensajes: 17
Antigüedad: 13 años, 4 meses
Puntos: 0
Respuesta: Reconocer y sustituir un enlace(url) con PHP

Ya lo solucione y hazta funciona como queria
Código PHP:
Ver original
  1. function url($text){
  2.         $text = html_entity_decode($text);
  3.         $text = " ".$text;
  4.         $text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_+.~#?&//=]+)','<a href="\1">\1</a>', $text);
  5.         $text = eregi_replace('(((f|ht){1}tps://)[-a-zA-Z0-9@:%_+.~#?&//=]+)', '<a href="\1">\1</a>', $text);
  6.         $text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)', '\1<a href="http://\2">\2</a>', $text);
  7.         $text = eregi_replace('(@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3})', '<a href="site.com/profile?u=\1">\1</a>', $text);
  8.         return $text;
  9. }
  10.  
  11. $miTxt= "Por fin quedo solucionado www.site.com y los usuarios se veran por @usuario, vaya q me costo";
  12.  
  13. $txt_final = url($miTxt);
  14.  
  15. echo $txt_final;