- chr: documentation ( source)
- preg_replace_callback: documentation ( source)
- ord: documentation ( source)
<?php
function ccbreaker(string $input): string {
return preg_replace_callback(
'/[A-Z]/',
fn (array $match): string => ' '. chr(ord($match[0]) + 32),
$input
);
}
echo ccbreaker("policeSiren"). PHP_EOL;
echo ccbreaker("camelCasingTest") . PHP_EOL;