I am trying to write a simple program which takes every 4th letter
(not character) in a string (not counting spaces) and changes the case
to it's opposite (If it's in lower, change it to upper or vice versa).
What I have so far:
echo preg_replace_callback('/.{5}/', function ($matches){
return ucfirst($matches[0]);
}, $strInput);
Sample input:
The sky is blue
Desired result:
The Sky iS bluE
# ^4th ^8th ^12th