Last active
March 18, 2020 18:44
-
-
Save wrabit/ce08834fb1adc0b4fbb5a011ab5fbc87 to your computer and use it in GitHub Desktop.
PHP: Camel case to title case function
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
if (!function_exists('camel_to_title')) { | |
function camel_to_title($string = '') | |
{ | |
// let's create spaces | |
$intermediate = preg_replace('/(?!^)([[:upper:]][[:lower:]]+)/', ' $0', $string); | |
// now upper case words | |
return mb_convert_case($intermediate, MB_CASE_TITLE); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment