ucwords() function is used to capitalize the first character of each word in a string.

<?php
$var_string = "hello world";
$result = ucwords($var_string);
echo $result; 
?>

Output:

Hello World