<?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',
'123FOOBar' => '123-foo-bar',
'123FooBAR' => '123-foo-bar',
'FooBAR123' => 'foo-bar-123',
'FOOBar123' => 'foo-bar-123',
];
foreach ( $test_values as $key => $val ) {
echo "$key: " . camelToUS($key) . " => " . (camelToUS($key) == $val) . "\n";
}
?>
PD9waHAKCmZ1bmN0aW9uIGNhbWVsVG9VUygkc3RyaW5nLCAkdXMgPSAiLSIpIHsKICAgIHJldHVybiBzdHJ0b2xvd2VyKHByZWdfcmVwbGFjZSgKICAgIAknLyg/PD1cZCkoPz1bQS1aYS16XSl8KD88PVtBLVphLXpdKSg/PVxkKXwoPzw9W2Etel0pKD89W0EtWl0pLycsICR1cywgJHN0cmluZykpOwp9CgokdGVzdF92YWx1ZXMgPSBbCiAgICAnZm9vJyAgICAgICA9PiAnZm9vJywKICAgICdmb29CYXInICAgID0+ICdmb28tYmFyJywKICAgICdmb28xMjMnICAgID0+ICdmb28tMTIzJywKICAgICcxMjNGb28nICAgID0+ICcxMjMtZm9vJywKICAgICdmb29CYXIxMjMnID0+ICdmb28tYmFyLTEyMycsCiAgICAnZm9vMTIzQmFyJyA9PiAnZm9vLTEyMy1iYXInLAogICAgJzEyM0Zvb0JhcicgPT4gJzEyMy1mb28tYmFyJywKICAgICcxMjNGT09CYXInID0+ICcxMjMtZm9vLWJhcicsCiAgICAnMTIzRm9vQkFSJyA9PiAnMTIzLWZvby1iYXInLAogICAgJ0Zvb0JBUjEyMycgPT4gJ2Zvby1iYXItMTIzJywKICAgICdGT09CYXIxMjMnID0+ICdmb28tYmFyLTEyMycsCl07Cgpmb3JlYWNoICggJHRlc3RfdmFsdWVzIGFzICRrZXkgPT4gJHZhbCApIHsKICAgZWNobyAiJGtleTogIiAuIGNhbWVsVG9VUygka2V5KSAuICAiID0+ICIgLiAoY2FtZWxUb1VTKCRrZXkpID09ICR2YWwpIC4gIlxuIjsKfQoKPz4=