Created
December 4, 2013 08:17
-
-
Save devster/7783986 to your computer and use it in GitHub Desktop.
Transform a camel case string to an underscore string
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 | |
/** | |
* Transform a camel case string to an underscore string | |
* | |
* @param string $str | |
* @return string | |
*/ | |
public static function camelCaseToUnderscore($str) | |
{ | |
return strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $str)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment