This function converts a string to title case. It first converts the entire string to lowercase using strtolower, then uses ucwords to capitalize the first letter of each word. This is useful for formatting text to make it more readable or aesthetically pleasing.
PHP Function:
function toTitleCase($str) { return ucwords(strtolower($str)); }
// Example
echo toTitleCase('hello, world!'); // 'Hello, World!'
echo toTitleCase('PHP IS GREAT'); // 'Php Is Great'