Skip to content

Instantly share code, notes, and snippets.

@falsecz
Created June 5, 2012 12:10
Show Gist options
  • Save falsecz/2874628 to your computer and use it in GitHub Desktop.
Save falsecz/2874628 to your computer and use it in GitHub Desktop.
Underscore CamelCase PascalCase
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