PHP ucwords() Function is used to convert the first character of each word to uppercase in string. The ucwords() is an in-built function of PHP.
Syntax :
ucwords(string, separator) ;
Parameters ,
string : Required. It is string to convert the first character of each word to uppercase.
separator : Optional. It is the words separator characters. Default separator characters may be as below.
- Space
- \t - tab
- \n - newline
- \r - carriage return
- \f - form feed
- \v - vertical tab
The ucwords() Function returns string with first character of each word to uppercase.
Similar function of ucwords() :
strtoupper() : It converts a whole string into uppercase.
strtolower() : It converts a whole string into lowercase.
lcfirst() : It converts only the first character of a string into lowercase.
ucfirst() : It converts only the first character of a string into uppercase.
Let's see below example to understand php ucwords() Function in details.
Comments