PHP Tutorial PHP Advanced PHP Resources
Python Java C++ C C# PHP R SQL DS Algo InterviewQ

PHP - String ucwords() Function



The PHP String ucwords() function returns the string with first character of each word of the specified string in the uppercase. Any symbol, space, special character or number in the string is ignored while applying this function. Only Alphabets are converted.

Syntax

ucwords(string)

Parameters

string Required. Specify the string to convert

Return Value

true if the size of the array is zero, else returns false.

Example:

In the example below, ucwords() function returns a string with first character of each word of the string MyString in the uppercase.

<?php
$MyString = "heLLo world!";
$NewString = ucwords($MyString);

echo $NewString."\n";
?>

The output of the above code will be:

HeLLo World!

❮ PHP String functions

5