NYCPHP Meetup

NYPHP.org

[nycphp-talk] Finding and encoding http:// and www in strings

Ben Sgro (sk) skyline at publicmine.com
Wed Nov 29 19:10:59 EST 2006


Hello all,

I have a string
$str = "This is the link to my website http://www.google.com";

I want to 'encode' the link to be a clickable link, <a 
href=http://www.google.com>www.google.com</a>.
The text would now be;
"This is the link to my website <a 
href=http://www.google.com>www.google.com</a>";

What is the best way to do this? Samples code or a lib/class would be 
helpful as well.

Thanks,

- Ben

note: I also want it to work on both www.google.com & http://www.google.com 




More information about the talk mailing list