Archive for July 6th, 2012

String Formatting : length, count and occurrences in PHP

 

Lower to Upper

<?php
$str = "Mary Had A Little Lamb and She LOVED It So";
$str = strtoupper($str);
echo $str; // Print ==> MARY HAD A LITTLE LAMB AND SHE LOVED IT SO
?>
 
Upper to Lower
 
<?php
$str = "Mary Had A Little Lamb and She LOVED It So";
$str = strtolower($str);
echo $str; // Print ==> mary had a little lamb and she loved it so
?>
 
Capitalise First Character
 
<?php
$foo = 'hello world!';
$foo = ucfirst($foo);
echo $foo; // Print ==> Hello world!
?>
 

Read more »

Last updated by at .