PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
A string parser would be the solution then, that uses preg_match (or more likely preg_match_all) with the PREG_OFFSET_CAPTURE flag.. if I get time (which is likely) and I get bored (even more likely) later then I will give writing one a go.
cool, thanks!
Let me explain what I'm doing a little better.
I'm trying to convert a file that has both one and two characters long tokens.
First, I replace the two character long tokens so the one longs don't screw up the two longs.
Then, I replace the one character long ones.
However, let's say the character "o" is the "cat" token and the character "horse" is a two long token that has already been replaced.
When "o" is replaced by "cat", the "horse" that has already been replaced becomes "hcatrse".
That doesn't achieve what is asked for, that just replaces the 3rd occurance of e in a string.
The problem here is that the replacement value for the 1st search contains a matching string for the 2nd search, so the 1st replacement is broken with the 2nd replacement. (note the e in Dear( gets replaced with Sally( in the example)
I started on a function, but then my employers decided to drop a bomb on me, also known as a notification of redundancy, so I am scrambling for a new job atm