Share on Google+Share on Google+

PHP Change Case

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

Advertisements

Posted on: February 24, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial 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.