PHP ucwords() Function

Example

Convert the first character of each word to uppercase:

<?php
echo ucwords("hello world");
?>

Run Instance

Definition and Usage

The ucwords() function converts the first character of each word in the string to uppercase.

Note:This function is binary safe.

Related Functions:

  • lcfirst() - Convert the first character of the string to lowercase
  • strtolower() - Convert the string to lowercase
  • strtoupper() - Convert the string to uppercase
  • ucfirst() - Convert the first character of the string to uppercase

Syntax

ucwords(string)
Parameter Description
string Required. Specifies the string to be converted.

Technical Details

Return Value: Return the converted string.
PHP Version: 4+