Replace string within string with certain characters
Posted: Tue Dec 22, 2009 11:06 am
Is there a way to put an anchor href tag around every word in $str with the characters "http://" or "https://"?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
$newstring = preg_replace('#\b(https?://\S*)\b#i', '<a href="$1">$1</a>', $str);