I have the following code:
<?
$string = 'SUV';
$patterns[0] = '/SUV/';
$patterns[1] = '/SUV/';
$replacements[0] = 'SUV (Sports Utility Vehicle)';
$replacements[1] = 'SUV (Sports Utility Motor Vehicle)';
echo preg_replace($patterns,$replacements,$string,1);
?>
The result is: SUV (Sports Utility Motor Vehicle) (Sports Utility Vehicle)
What I am trying to avoid is when I searched for the second SUV, it was only found ONCE in the original string. I don't want the second replacement to occur. This is the result I was hoping for:
SUV (Sports Utility Vehicle)
So say my original string contains SUV 50 times, I want those SUV matches to be replaced with one of 50 replacement pattern. I don't want it to replace already replaced words and count those as one of the 50. I want the replace to occur linearlly if you will. Make sense?
TIA