Skip to content

Instantly share code, notes, and snippets.

@andrewspear
Last active December 23, 2015 18:59
Show Gist options
  • Save andrewspear/6680029 to your computer and use it in GitHub Desktop.
Save andrewspear/6680029 to your computer and use it in GitHub Desktop.
Convert camel case string to a title case string in PHP
<?
function camelCaseToTitleCase($string) {
return ucwords(preg_replace('/(?!^)[A-Z]{2,}(?=[A-Z][a-z])|[A-Z][a-z]/', ' $0', $string));
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment