How to Change a String to All Uppercase Letters in PHP?

Problem:

You have a string which has all the letters in lowercase or few letters in lowercase. You want to change the string to all uppercase letters.

Solution:

Use mb_strtoupper() function to convert all the lowercase letters to uppercase letters. See the following example-

<?php
$string = "To iterate is human, to recurse divine.";
echo "Original string: ". $string. "<br />";
$string = mb_strtoupper($string);
echo "Converted string: ". $string;
?>

[wpdm_file id=139]

Output:
Original string: To iterate is human, to recurse divine.
Converted string: TO ITERATE IS HUMAN, TO RECURSE DIVINE.