ucwords() uppercases the first ASCII lowercase character of each word. You can optionally provide a custom separator list.
$text = 'php string functions';
echo ucwords($text); // Php String Functions
Start with this current pattern. The examples below are retained, corrected where necessary, and expanded for additional variations and output.
$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]);
| Parameter | DESCRIPTION |
|---|---|
$input_str | Required : Input string |
$delimiters | Optional : contains the word separator characters. |
$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
$str = 'hello-world_php-tutorial';
echo ucwords($str, "-_"); // Output: Hello-World_Php-Tutorial
$str = 'привет мир';
echo mb_convert_case($str, MB_CASE_TITLE, "UTF-8"); // Output: Привет Мир
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.