Possible Duplicate:
Preg Replace - replace second occurance of a match
I have a string that includes the word rules
twice. I need to find and replace the 2nd word. Tried fooling around with str_replace()
but couldn't get anything, the 4th parameter wasn't what I expected.
Here is an example string:
http://localhost/proj1/modstart/admin/index.php?i=rules&sid=397ab1f6b8eb8a17787438a7e2e60ea3&mode=rules
After my replace it should look like this:
http://localhost/proj1/modstart/admin/index.php?i=rules&sid=397ab1f6b8eb8a17787438a7e2e60ea3&mode=manage
I read that preg_replace()
could help, but I don't know how to write patterns.
Ideas?
P.S: Don't suggest splitting the string into two variables, that wouldn't serve my needs.