What PHP function can be used to capitalize the first letter of each word in a string?

To capitalize the first letter of each word in a string, you can use the ucwords() function in PHP. This function takes a string as input and returns the string with the first letter of each word capitalized. It is a simple and effective way to achieve this formatting in PHP.

$string = "hello world";
$capitalizedString = ucwords($string);
echo $capitalizedString;