Basically I have a situation like this:
$search = array(
'?',
'?'
);
$replace = array(
'1',
'2'
);
When I try:
str_replace($search,$replace,"First value: ? Second Value: ?");
I get:
"First value: 1 Second Value: 1" //> Notice the "1" repetead
Instead of
"First value: 1 Second Value: 2"
How could I get the second result (even without the use of str_replace)?
preg_replace has a limit parameter so you can use that instead:
You can use array_fill to build the search array: