Replace string within string with certain characters
Moderator: General Moderators
-
BriceHulse
- Forum Newbie
- Posts: 2
- Joined: Tue Dec 22, 2009 11:03 am
Replace string within string with certain characters
Is there a way to put an anchor href tag around every word in $str with the characters "http://" or "https://"?
Re: Replace string within string with certain characters
Code: Select all
$newstring = preg_replace('#\b(https?://\S*)\b#i', '<a href="$1">$1</a>', $str);