<?php
function camelToUS($string, $us = "-") {
'/(?<=\d)(?=[A-Za-z])|(?<=[A-Za-z])(?=\d)|(?<=[a-z])(?=[A-Z])/', $us, $string));
}
$test_values = [
'foo' => 'foo',
'fooBar' => 'foo-bar',
'foo123' => 'foo-123',
'123Foo' => '123-foo',
'fooBar123' => 'foo-bar-123',
'foo123Bar' => 'foo-123-bar',
'123FooBar' => '123-foo-bar',
];
foreach ( $test_values as $key => $val ) {
echo "$key: " . camelToUS($key) . " => " . (camelToUS($key) == $val) . "\n";
}
?>
PD9waHAKCmZ1bmN0aW9uIGNhbWVsVG9VUygkc3RyaW5nLCAkdXMgPSAiLSIpIHsKICAgIHJldHVybiBzdHJ0b2xvd2VyKHByZWdfcmVwbGFjZSgKICAgIAknLyg/PD1cZCkoPz1bQS1aYS16XSl8KD88PVtBLVphLXpdKSg/PVxkKXwoPzw9W2Etel0pKD89W0EtWl0pLycsICR1cywgJHN0cmluZykpOwp9CgokdGVzdF92YWx1ZXMgPSBbCiAgICAnZm9vJyAgICAgICA9PiAnZm9vJywKICAgICdmb29CYXInICAgID0+ICdmb28tYmFyJywKICAgICdmb28xMjMnICAgID0+ICdmb28tMTIzJywKICAgICcxMjNGb28nICAgID0+ICcxMjMtZm9vJywKICAgICdmb29CYXIxMjMnID0+ICdmb28tYmFyLTEyMycsCiAgICAnZm9vMTIzQmFyJyA9PiAnZm9vLTEyMy1iYXInLAogICAgJzEyM0Zvb0JhcicgPT4gJzEyMy1mb28tYmFyJywKXTsKCmZvcmVhY2ggKCAkdGVzdF92YWx1ZXMgYXMgJGtleSA9PiAkdmFsICkgewogICBlY2hvICIka2V5OiAiIC4gY2FtZWxUb1VTKCRrZXkpIC4gICIgPT4gIiAuIChjYW1lbFRvVVMoJGtleSkgPT0gJHZhbCkgLiAiXG4iOwp9Cgo/Pg==