Witam napisałem sobie taka funkcje
  1. $text = "test www.google.com/index.php?lol=3 testestsetse www.wp.pl";
  2.  
  3. echo make_url($text);
  4. function make_url($text) {
  5. $return = array();
  6. $reg = "/(www)\.[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
  7. if(preg_match($reg, $text))
  8. {
  9. $txt = explode(' ', $text);
  10. foreach($txt as $t)
  11. {
  12. if(preg_match($reg, $t, $url))
  13. {
  14. $return[] = preg_replace($reg, '<a href="'.$url[0].'" rel="nofollow">'.$url[0].'</a>', $t);
  15.  
  16. } else {
  17. $return[] = $t;
  18. }
  19. }
  20. $txt = implode(' ', $return);
  21. return $txt;
  22. }
  23. return $text;
  24. }

ale nie jestem z niej zadowolony wydaje mi się nie optymalna ale nic innego mi nie przychodzi do głowy proszę o pomoc w optymalizacji jej