Witam. Chciałem na swojej stronie umieścić funkcję make_clickable() ale coś nie działa sad.gif Funkcja wygląda tak:
  1. <?
  2. function make_clickable($text)
  3. {
  4.  
  5. // pad it with a space so we can match things at the start of the 1st line.
  6. $ret = ' ' . $text;
  7.  
  8. // matches an \"****x://yyyy\" URL at the start of a line, or after a space.
  9. // ****x can only be alpha characters.
  10. // yyyy is anything up to the first space, newline, comma, double quote or <
  11. $ret = preg_replace(&#092;"#([trn ])([a-z0-9]+?){1}://([w-]+.([w-]+.)*[w]+(:[0-9]+)?(/[^ \"nrt<]*)?)#i\", '1<a href=\"2://3\" target=\"_blank\">2://3</a>', $ret);
  12.  
  13. // matches a \"wwwŚftp.xxxx.yyyy[/zzzz]\" kinda lazy URL thing
  14. // Must contain at least 2 dots. xxxx contains either alphanum, or \"-\"
  15. // zzzz is optional.. will contain everything up to the first space, newline,
  16. // comma, double quote or <.
  17. $ret = preg_replace(&#092;"#([trn ])(wwwŚftp).(([w-]+.)*[w]+(:[0-9]+)?(/[^ \"nrt<]*)?)#i\", '1<a href=\"http://2.3\" target=\"_blank\">2.3</a>', $ret);
  18.  
  19. // matches an email@domain type address at the start of a line, or after a space.
  20. // Note: Only the followed chars are valid; alphanums, \"-\", \"_\" and or \".\".
  21. $ret = preg_replace(&#092;"#([n ])([a-z0-9-_.]+?)@([w-]+.([w-.]+.)*[w]+)#i\", \"1<a href=\"mailto:2@3\">2@3</a>\", $ret);
  22.  
  23. // Remove our padding..
  24. $ret = substr($ret, 1);
  25.  
  26. return($ret);
  27. } 
  28. ?>


a używam jej tak:

  1. <? //...
  2.  $tresc = make_clickable($tresc); //zmienna $tresc jest tutaj pobierana z bazy i na pewną są w niej linki takie jak 
  3. ww.costam.pl, http://costam.pl/costam etc...
  4.  
  5. echo $tresc;
  6. //...
  7. ?>


i żaden z linków nie jest zmieniany sad.gif
Proszę o jakąś wskazówkę jak zrobić żeby działało biggrin.gif

Pozdr.