Sunday, March 13, 2011

Uppercase the first character of each word in a string


Uppercase the first character of each word in a string
Syntax : string ucwords ( string $str )
Returns a string with the first character of each word in str capitalized, if that character is alphabetic.
Parameters :
str : The input string.
Return Values :
Returns the modified string
Example :


<?php
        $titleString = "a title that could use some hELP";
        $ucTitleString = ucwords($titleString);
        echo "Old title - $titleString <br />";
        echo "New title - $ucTitleString";
?>

Display Output :
Old title – a title that could use some hELP
New title – A Title That Could Use Some HELP

No comments:

Post a Comment