Home Tutorial Php Phpbasics Tutorial PHP Change Case

 
 

PHP Change Case
Posted on: February 24, 2010 at 12:00 AM
In this current tutorial we will study how to change a string from normal text to all lower case text, to all upper case text and convert every first character to uppercase.

PHP String Change Case:

In this current tutorial we will study how to change a string from normal text to all lower case text, to all upper case text and convert every first character to uppercase.

To convert a string to all lowercase text we will use strtolower() function, to convert a string to all uppercase text we will use strtoupper() function and ucword() function is used to convert every first character of each word to uppercase.

PHP String Change Case Example:

<?php

$string="This is a String";

$string=strtolower($string);

echo $string;

?>

Output:

this is a string

Example:

<?php

$string="This is a String";

$string=strtoupper($string);

echo $string;

?>

Output:

THIS IS A STRING

Example:

<?php

$string="This is a String";

$string=ucwords($string);

echo $string;

?>

Output:

This Is A String

Related Tags for PHP Change Case:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.