DEV Community

Discussion on: Daily Challenge #188 - Break camelCase

Collapse
 
fjones profile image
FJones • Edited
function ccbreaker(string $input): string {
    return preg_replace_callback(
        '/[A-Z]/',
        fn (array $match): string => ' '. chr(ord($match[0]) + 32),
        $input
    );
}

Rare case where PHP is concise.

3v4l.org/1vCqj