I have a string in which I want to replace a series of substrings. I then have an array of strings, each of which represents one substring I want to replace. I have a second array of strings, where each element represents what I want to replace the substring with. Hopefully that is clear.
Unfortunately, str_replace does not work, as it takes the first search string and the first replacement string, and goes through the whole string replacing each substring that matches the search string with the replacement string. Of course, this is exactly as str_replace is documented. However, the behavior I want is to replace the first substring with the replacement string, then move to the next serach string and the next replacement string and continue ...
preg_replace seems to imply it will do that if you include the limit variable. I tried that, but unfortunately, it complained about my string ... the sting contains essentially HTML.
any ideas?
thanks,
ron