3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tests = [ 'getADogThenROCKInTheUSA', 'SomeOfTheWords', 'getADog', 'ADog', 'aDog', 'XML', 'SimpleXMLReader', 'FREE4NOW', '123ABC', 'DEF456', 'ghi789', 'wtf666Omg', 'PHP8Point3', ]; foreach ($tests as $test) { printf("%25s => %s\n", $test, strtolower(preg_replace('/(?>[A-Z]?[a-z]+|[A-Z]+(?=[A-Z][a-z]|[^A-Za-z])|[^A-Za-z]+)\K(?!$)/', '-', $test))); }

preferences:
39.44 ms | 406 KiB | 5 Q