Created
December 21, 2011 14:53
-
-
Save jamiefdhurst/1506303 to your computer and use it in GitHub Desktop.
ucwords() replacement (from when i was daft)
This file contains hidden or 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
function caps($str) { | |
$split = explode(' ', $str); | |
for($i = 0; $i < count($split); $i++) { | |
$split[$i] = ucfirst(strtolower($split[$i])); | |
} | |
$str = implode(' ', $split); | |
return $str; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In my defence, the function name is 3 characters shorter. Note the lack of pointers knowledge, preg_split() usage, BUT my surprising knowledge of ucfirst().