I want to use preg_replace with one pattern and an array of replacements that are all different. In other words, for each occurrence of the match I want to iterate down the replacements array for a replacement.
Is there any way to do this?
I tried using preg_replace_callback - the callback accepts an array of matches but has to only return one string- no way to tell which match you are replacing.
I also tried using the count param and passing it the callback function - it's 0 every time and after the preg_replace is done it and thentells the total number of matches.