I am trying to figure out how to get ereg_replace / preg_replace to replace a match only once.
Here is my example:
$text = "[foo] bah [foo] moo [foo] boo\n";
$ans = ereg_replace("\[foo\]{1}","FOO",$text);
or
$ans = preg_replace("/\[foo\]{1}/",$text,"FOO");
The answer I get for both I run the example
echo $ans;
FOO bah FOO moo FOO boo
Can any tell me what I am doing wrong ? I am trying only to replace the match once. eg
FOO bah [foo] moo [foo] boo
Any help would be appreciated...
Cheers
John Clegg
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php