How can we change the first letters to capital letter of “first name” and “last name” from single name string using PHP ?

ucwords() helps to uppercase the first character of each word in a string.

First letter to Capital letter of “First name” and “Last name” using PHP
<?php
$name = ‘rajesh varma’;
$name = ucwords($name);
?>

Output : Rajesh Varma