Last updated on March 13, 2023
In PHP, the ucwords() function converts the first letter of each word into uppercase. It takes one required parameter. For example if you pass a string value “programming language” into the ucwords() function then it would return “Programming Language”.
Syntax
ucwords(string $anyString)
Parameters
It takes one required parameter. The should be string so that function can convert the first letter into uppercase.
Supported Versions
Example
echo ucwords("programming");
// Output: Programming
In the above example, a single word is passed into ucwords() function that converts the first letter into uppercase.
echo ucwords("programming is best");
// Output: Programming Is Best
In the above example, a phrase that contains three words is passed into the ucwords() function. As you can see in the output, the function converted the first letter of each word into uppercase.
Conclusion
This article demonstrates how can you use the PHP ucwords() function. It converts each letter of the string into uppercase and to do that you need to pass the string into the function as an argument.