Home >>PHP String Functions >PHP ucwords() Function
PHP ucwords() function is used to convert the first character of each word in a string to upper-case. It takes a string as an input and converts the first character of each word to uppercase and the other characters remain unchanged. It is binary-safe.
Syntax:
ucwords( $string, $separator);
Parameter | Description |
---|---|
string | This is a required parameter. This parameter defines the string to convert. |
separator | This is an optional parameter. This parameter defines the word separator character. |
Here is an example of ucwords() function in PHP:
<html> <body> <?php echo ucwords("hello everyone.. i am new here"); ?> </body> </html>
Here is an another example of ucwords() function in PHP:
<html> <body> <?php echo ucwords("hello everyone.i am new here.my name is jerry", "."); ?> </body> </html>