SQL PHP HTML ASP JavaScript articles and free scripts to download
 

Converting the first letter to upper case of every word

We can use php string function ucwords to change all first character of words present in a string to upper case or capitalize the first letter of each word.

Here is the syntax

$output=ucwords($input_str);

You can see the output string is $output and input string is $input_str in the above example.


Now let us try with one example

Here is a string variable $str with some string inside it. We will use ucwords to capitalize first chars of every words inside it.

$str="welcome to plus2net.com. you can learn web programming here";
$str=ucwords($str);
echo $str;

The output is here

Welcome To Plus2net.com. You Can Learn Web Programming Here



You can read how to change all the letters to upper case here



Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked


Join Our Email List
Email:  
For Email Newsletters you can trust
String Functions
PHP Sections