From: "John Clegg" <[EMAIL PROTECTED]>
> I am trying to figure out how to get ereg_replace / preg_replace to
> replace a match only once.
The fourth parameter to preg_replace() is an integer limit to how many
matches you want to allow. So, if you only want 1 replacement to occur, pass
1. :)
---Jo
Hi
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
2 matches
Mail list logo