Created
April 9, 2018 11:26
-
-
Save scones/e09c30e696246fda14578bcf8ab4910a to your computer and use it in GitHub Desktop.
de-deprecate this: https://stackoverflow.com/a/5194470/2004683
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function decamelize($input_string) { | |
return preg_replace_callback( | |
'#(^|[a-z])([A-Z])#', | |
function (array $matches) { | |
$result = ''; | |
if (0 === strlen($matches[1])) | |
$result = $matches[2]; | |
else | |
$result = "{$matches[1]}_{$matches[2]}"; | |
$result = strtolower($result); | |
return $result; | |
}, | |
$input_string | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment