PHP ucwords() Function

Definition

The ucwords() function takes string and converts the first letter of each word to an uppercase character.

Syntax

PHP ucwords() Function has the following syntax.

string ucwords ( string str )

Parameter

str is the string we want to convert.

Return

PHP ucwords() function returns the converted string.

Example

Convert words in a string to uppercase


<?PHP//  w  w  w . jav  a  2 s  .c om
$string = "this is a test from java2s.com"; 
$a = ucwords($string); 
print($a);
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions