PHP Quicky - Upper Case All Words In A String
Category: string manipulation
Level: beginner
Here's an easy one. Let's say you want to pump out a headline and need nice formatting, as in uppercasing each word. For example:
"Who Else Wants To Read An Every Word Uppercased Headline?"
well, easy enough. No need for complex code, a simple elegant solution resides in the "ucwords()" function.
$string= "Who else wants to read an every word uppercased headline?"; $niceHeadline = ucwords($string); echo $niceHeadline; // print the headline above code block
WP4H
Cheers,
Kathy