PHP - ucwords() Function
The PHP ucwords() function is used to return the string with first character of each word of the specified string in the uppercase. Any symbol, space, special character or number in the string is ignored while applying this function. Only Alphabets are converted.
Syntax
ucwords(string)
Parameters
string |
Required. Specify the string to convert |
Return Value
true if the size of the array is zero, else returns false.
Example:
In the below example, ucwords() function to used to return a string with first character of each word of the string MyString in the uppercase.
<?php $MyString = "heLLo world!"; $NewString = ucwords($MyString); echo $NewString."\n"; ?>
The output of the above code will be:
HeLLo World!
❮ PHP String functions