Example:
string1="ah ah I love you ah ah ah ah";
After replacement:
string1="ah ah I love you ah thank you ah ah";
The above means ‘ah’ at fourth position should be replaced by ‘thank you’
I don’t know how to code task above by PHP. Can you help me?
How it works: Each time
ahmatches the callback function is invoked. The static$countvariable is increased and when it’s the fourth match it returns the replacement string, otherwise the originally matched string.