Let's say I have a string where I know a certain substring repeats 5 times. I want to replace occurance (0,2,3) with another string but leave occurence 1,4 alone. Or just replace the first 3 occurences and let the rest live. Of course this needs to be case sensitive/insensitive.
While I'm at it I want to replace from the end and replace occurence -1 too which is last. Can you feel my pain?
The script provided has been written and tested on PHP5 and works. It should be PHP4 friendly. If you got problems… holler.
Update: When I pasted this script I had some problems with the slashes that got lost on the way. I did not notice it and most who use it fixed them but I changed the script now to a functional version.
This function should not be abused but it does have some legitimate uses. Google.com would not consider them legitimate but there are …
So use this to get the Google search engine results (SERPs) in your PHP script easily but at your own risk. And use common sense and do not hammer servers!