PHP Quicky - Upper Case All Words In A String

2 replies
Hello all, time for another PHP quicky

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.

Code:
$string= "Who else wants to read an every word uppercased headline?";
$niceHeadline = ucwords($string);

echo $niceHeadline;  // print the headline above code block
enjoy!
WP4H
#case #php #quicky #string #upper #words

Trending Topics