Helping ordinary people create extraordinary websites!
   

How to Convert to Lowercase and Uppercase in PHP

Monday, 30th August 2010
by Guest

I am using PHP for my first scripting language and am just becoming somewhat familiar with it. I would like to be able to maneuver between uppercase and lowercase at will with PHP. Can you please let me know how?





Vader
Hi,
To use PHP to convert all letters in a string to uppercase you use the following:

$string = strtoupper($string);

To convert a string to lowercase you use the following PHP code:

$string = strtolower($string);

Now if you are looking to make the first character in a string uppercase:

$string = ucfirst($string);

And if you want to make the first character in each word of the string uppercase:

$string = ucwords($string);


- Vader
Monday, 30th August 2010
Votes:
17
14

SPREAD THE WORD!
Tell a Friend

GET OUR NEWS


Developer Resources