Try this one
preg_replace('/(http:\/\/[^\s<>]+)/i', '<a href="$1"
target="_blank">$1</a>', $str);
Take out the target="_blank" if you want.
-Rob
Tim Lieberman wrote:
Look at preg_replace()
Sorry I don't have any code handy.
-Tim
Ben Sgro (sk) wrote:
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
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk
NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com
Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk
NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com
Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk
NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com
Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php