Monday, 13 August 2018

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-
1
2
3
4
5
6
<?php
$string = "To iterate is human, to recurse divine.";
echo "Original string: ". $string. "<br />";
$string = mb_strtoupper($string);
echo "Converted string: ". $string;
?>
Output:Original string: To iterate is human, to recurse divine.
Converted string: TO ITERATE IS HUMAN, TO RECURSE DIVINE.

0 comments:

Post a Comment