PHP String change case

PHP String change case


Posted in : PHP Posted on : January 7, 2011 at 6:22 PM Comments : [ 0 ]

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

Download Source Code

Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics