3v4l.org

run code in 300+ PHP versions simultaneously
<?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"; }

preferences:
31.95 ms | 406 KiB | 5 Q