<?php
$strings = [
"tHe iPad hAS gONE ouT of STOCK
PoWER uP YOur iPhone
wHAT moDEL is YOUR aPPLE iPHOne",
"fly the chopper to the helipad.
an audiphone is a type of hearing aid
consisting of a diaphragm that, when
placed against the upper teeth, conveys
sound vibrations to the inner ear"
];
foreach ($strings as $string) {
echo preg_replace_callback('~\bi\K(?:pad|phone)\b|[a-z]+~', function($m) {return ucfirst($m[0]);}, strtolower($string));
echo "\n---\n";
}
The iPad Has Gone Out Of Stock
Power Up Your iPhone
What Model Is Your Apple iPhone
---
Fly The Chopper To The Helipad.
An Audiphone Is A Type Of Hearing Aid
Consisting Of A Diaphragm That, When
Placed Against The Upper Teeth, Conveys
Sound Vibrations To The Inner Ear
---
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
The iPad Has Gone Out Of Stock
Power Up Your iPhone
What Model Is Your Apple iPhone
---
Fly The Chopper To The Helipad.
An Audiphone Is A Type Of Hearing Aid
Consisting Of A Diaphragm That, When
Placed Against The Upper Teeth, Conveys
Sound Vibrations To The Inner Ear
---