Home Tutorial Php Phpbasics Tutorial PHP Change Case

 
 

Share on Google+Share on Google+
PHP Change Case
Posted on: February 24, 2010 at 12:00 AM
Advertisement
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

Advertisement

Related Tags for PHP Change Case:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: February 24, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com