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

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 you can learn web programming here";
echo $str;
The output is here

Welcome To You Can Learn Web Programming Here

Changing first character of first word only to uppercase.

Instead of changing first char of all the words to upper case we can change to upper case for the first char of (only ) first word of total sting by using ucfirst() function.
$ar="welcome to plus2net php section";
echo ucfirst($ar);
The output is here
Welcome to plus2net php section

how to change all the letters to upper case

Your Rating

PHP String Functions

Post Comment This is for short comments only. Use the forum for more discussions.

HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us
©2000-2018 All rights reserved worldwide Privacy Policy Disclaimer