Skip to content

Instantly share code, notes, and snippets.

@toshimaru
Created July 3, 2012 08:43
Show Gist options
  • Save toshimaru/3038546 to your computer and use it in GitHub Desktop.
Save toshimaru/3038546 to your computer and use it in GitHub Desktop.
camelize / decamelize function
<?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