-
-
Save Cezarion/8004157 to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
/** | |
* Transforms an under_scored_string to a camelCasedOne | |
*/ | |
function camelize($scored) { | |
return lcfirst( | |
implode( | |
'', | |
array_map( | |
'ucfirst', | |
array_map( | |
'strtolower', | |
explode( | |
'_', $scored))))); | |
} | |
/** | |
* Transforms a camelCasedString to an under_scored_one | |
*/ | |
function underscore($cameled) { | |
return implode( | |
'_', | |
array_map( | |
'strtolower', | |
preg_split('/([A-Z]{1}[^A-Z]*)/', $cameled, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment