How to make the first character of a word in uppercase?

Is there any function in PHP to make the first character of the word uppercase, or should I write it with a regular expression?

+5
source share
5 answers

Use the ucfirst function .

+11
source
$word = ucfirst($word);
+4
source

$firstlettersuppercased = ucwords($originalstring);

This will use the first letter of each word in the original string $.

+1
source
$word_ = "your name here";
echo ucfirst($word_); // Your name here
echo ucwords($word_); // Your Name Here
+1
source

Try using the function ucwords().

0
source

All Articles