Created
May 16, 2012 05:37
-
-
Save pjxiao/2707772 to your computer and use it in GitHub Desktop.
Covert CamelCase string to snake_case. / キャメルケースをスネークケースに変換する。
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
<? | |
/** | |
* Covert CamelCase string to snake_case | |
* キャメルケースの文字列をスネークケース (アンダースコア区切り)文字列に変換します。 | |
* @param string CamelCase | |
* @return string snake_case | |
*/ | |
function camelToSnake($str) { | |
return strtolower(preg_replace('/\B([A-Z]+)/', '_\1', $str)); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment