ucwords() :Converting the first letter to upper case of each word

$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
Syntax
$output=ucwords($input_str [,string $delimiters]);
ParameterDESCRIPTION
$input_strRequired : Input string
$delimitersOptional : contains the word separator characters.

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 :

Example: Capitalizing Words with Custom Delimiters

$str = 'hello-world_php-tutorial';
echo ucwords($str, "-_");  // Output: Hello-World_Php-Tutorial

Example: Capitalizing UTF-8 Strings

$str = 'привет мир';
echo mb_convert_case($str, MB_CASE_TITLE, "UTF-8");  // Output: Привет Мир

String Functions ucfirst(): To Change first char only to upper case of a string. how to change all the letters to upper case
Subhendu Mohapatra — author at plus2net
Subhendu Mohapatra

Author

🎥 Join me live on YouTube

Passionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.



Subscribe to our YouTube Channel here



plus2net.com











PHP video Tutorials
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer