Created
July 3, 2012 08:43
-
-
Save toshimaru/3038546 to your computer and use it in GitHub Desktop.
camelize / decamelize function
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
<?php | |
/** | |
* via: http://d.hatena.ne.jp/fbis/20070713/1184309659 | |
*/ | |
function camelize ($str) { | |
return str_replace(' ','',ucwords(str_replace('_',' ',$str))); | |
} | |
function decamelize ($str) { | |
return ltrim(preg_replace('/([A-Z])/e',"'_'.strtolower('$1')",$str),'_'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment