Re: Converting URL's to hyperlinks.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Daevid Vincent a écrit :
Maybe I misunderstood the OP,
  OP ?

but wouldn't this (or something like it) be
easier and cleaner than that mess below??
  No, it's dirty too.

$url = preg_replace("/(\w+@\w+\.[a-zA-Z]{2,3})/i", "<a
href='mailto:$1'>$1</a>", $url);
This violate the numerous RFC about mail addresses, and some other stuffs.


$url = preg_replace("/\s(http:\/\/)?(\w*\.?\w*\.[a-zA-Z]{2,3}.*?\s)/i", " <a
href='http://$2' target='_blank'>$2</a>", $url);

Same as previously. What about .info, .museum and so on tld ? The filter_var is well suited for this kind of job. Oh, and your regex isn't smart (you use the case insensitivity flag, but seek A-Z characters...) :D

--
Mickaël Wolff aka Lupus Michaelis
http://lupusmic.org

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux