*note, whenever you see a { it means a [ and } means ]
I'm messing around trying to make a ubb replacer and am running into a wierd issue (this is my first time playing with preg).
I've been able to successfuly replace the following string with the appropriate html code
And I'm using this code to replace it
and with that i get <a href="http://www.google.com">Google</a> without a hitch.
Now here's the problem, if I throw another url UBB link into that string, for example
I only get the following output <a href="http://www.yahoo.com">Yahoo</a>
I thought preg_replace was supposed to go through and replace each time it found the pattern. What am I doing wrong?
I'm messing around trying to make a ubb replacer and am running into a wierd issue (this is my first time playing with preg).
I've been able to successfuly replace the following string with the appropriate html code
Code:
{url=http://www.google.com}Google{/url}
And I'm using this code to replace it
PHP:
$url = "[url=http://www.google.com]Google[/url]";
echo preg_replace("|\[url=(.*)\](.*)\[/url\]|", "<a href=\"\\1\">\\2</a>", $url);
and with that i get <a href="http://www.google.com">Google</a> without a hitch.
Now here's the problem, if I throw another url UBB link into that string, for example
Code:
{url=http://www.google.com}Google{/url} and {url=http://www.yahoo.com}Yahoo{/url}
I only get the following output <a href="http://www.yahoo.com">Yahoo</a>
I thought preg_replace was supposed to go through and replace each time it found the pattern. What am I doing wrong?