Converting the first letter to upper case of each word

$output=ucwords($input_str [,string $delimiters]);
ParameterDESCRIPTION
$input_strRequired : Input string
$delimitersOptional : contains the word separator characters.
We can use php string function ucwords to change all first character of each words present in a string to upper case

Now let us try with one example

Here is a string variable $str with one 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

With delimiters

Here we have used , as word delimiters
$my_str="hello,welcome";
echo ucwords($my_str,',');
Output is here
Hello,Welcome
Now we will use | as delimiters
$my_str="hello,welcome|home";
echo ucwords($my_str,'|');
Output is here
Hello,welcome|Home
Using both , and | as delimiters
$my_str="hello,welcome|home";
echo ucwords($my_str,'|,');
Output is here
Hello,Welcome|Home

DEMO

Output :
Visitors Rating
Your Rating





PHP String Functions

Post your comments , suggestion , error , requirements etc here .




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