The `ucwords()` function in PHP capitalizes the first character of each word in a string. It's been available in PHP for many versions and works the same way in PHP 8.PHP 8.1 PHP 8.2. PHP 8.3 PHP and 8.4
Basic Syntax
<?php
ucwords(string $string, string $separators = " \t\r\n\f\v"): string
?>
Parameters
<?php
$string = "hello world";
echo ucwords($string); // Output: Hello World
?>
With Custom Separators
<?php
$string = "hello-world|goodbye-world";
echo ucwords($string, "-|"); // Output: Hello-World|Goodbye-World
?>
PHP 8.2 Notes
In PHP 8.2, `ucwords()` works the same as in previous versions. No changes were made to this function specifically in 8.2. However, PHP 8.2 introduced other string-related improvements like the new `str_split()` flag for multibyte strings