This section contains the detail about the changing case of string.
PHP String change case
In PHP, we can change the case of the String from lower case to upper and upper case to lower.
Changing case from lower to upper
For changing case from lower to upper, PHP provide us strtoupper() function. It coverts lower case letters to upper case and leaves the upper case letter and numbers as it is.
Given below example gives you a clear idea :
Example :
<?php $lowerStr = "Welcome to Devmanuals in 2011"; $upperStr = strtoupper($lowerStr); echo "Original string - $lowerStr <br />"; echo "String after conerting lower to upper : $upperStr"; ?>
Output :
Original string - Welcome to Devmanuals in 2011
String after conerting lower to upper : WELCOME TO DEVMANUALS IN 2011
Changing case from upper to lower
For changing case from lower to upper, PHP provide us strtolower() function. It coverts upper case letters to lower case and leaves the lower case letter and numbers as it is.
Example :
<?php $upperStr = "Welcome to Devmanuals in 2011"; $lowerStr = strtolower($upperStr); echo "Original string - $upperStr <br />"; echo "String after conerting lower to upper : $lowerStr"; ?>
Output :
Original string - Welcome to Devmanuals in 2011
String after conerting lower to upper : welcome to devmanuals in 2011
[ 0 ] Comments