PHP 7 ucwords() Function
Example
Convert the first character of each word to uppercase:
<?php
echo ucwords("hello world");
?>
Try it Yourself »
Definition and Usage
The ucwords() function converts the first character of each word in a string to uppercase.
Note: This function is binary-safe.
Related functions:
- ucfirst() - converts the first character of a string to uppercase
 - lcfirst() - converts the first character of a string to lowercase
 - strtoupper() - converts a string to uppercase
 - strtolower() - converts a string to lowercase
 
Syntax
ucwords(string, delimiters)
| Parameter | Description | 
|---|---|
| string | Required. Specifies the string to convert | 
| delimiters | Optional. Specifies the word separator character | 
Technical Details
| Return Value: | Returns the converted string | 
|---|---|
| PHP Version: | 4+ | 
| Changelog: | PHP 5.4 - Added the delimiters parameter | 
More Examples
Example
Convert the first character of each word to uppercase, with a custom word separator added:
<?php
echo ucwords("hello|world", "|");
?>
Try it Yourself »

