Example 1 — Title Case a Sentence
Capitalize each word in a phrase.
<?php
$text = "hello world from php";
echo ucwords($text), PHP_EOL; How It Works
- Split by spaces. PHP treats each space as a word break.
- Capitalize each start. The first letter of every word is changed.
- Keep the rest. Other letters remain lowercase.
- Print. You see
Hello World From Php.

