Created
June 5, 2012 12:10
-
-
Save falsecz/2874628 to your computer and use it in GitHub Desktop.
Underscore CamelCase PascalCase
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
protected function underScoreToCamelCase( $string ) { | |
return preg_replace( '/(?:^|_)(.?)/e', "strtoupper('$1')", $string ); | |
} | |
protected function underScoreToPamelCase( $string ) { | |
return preg_replace( '/_(.?)/e', "strtoupper('$1')", $string ); | |
} | |
protected function cameCaseToUnderScore( $string ) { | |
return strtolower( preg_replace( '/([^A-Z])([A-Z])/', "$1_$2", $string ) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment