Skip to content

Instantly share code, notes, and snippets.

@jamiefdhurst
Created December 21, 2011 14:53
Show Gist options
  • Save jamiefdhurst/1506303 to your computer and use it in GitHub Desktop.
Save jamiefdhurst/1506303 to your computer and use it in GitHub Desktop.
ucwords() replacement (from when i was daft)
function caps($str) {
$split = explode(' ', $str);
for($i = 0; $i < count($split); $i++) {
$split[$i] = ucfirst(strtolower($split[$i]));
}
$str = implode(' ', $split);
return $str;
}
@jamiefdhurst
Copy link
Author

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().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment