5 PHP Functions for Words Formatting

By | November 27, 2013

PHP functions are used for text formatting. Formatting like uppercase, lowercase and first letter uppercase can also be done using php functions, here is the 5 php functions for words/text formatting

  • ucwords
  • strtoupper
  • strtolower
  • ucfirst
  • lcfirst

 

ucwords()

Make each word’s first letter as capital letter

[code type=php]

$text = “freeze coders”;

$text1 = ucwords($text); // Output –  Freeze Coders

[/code]

 

strtoupper()

strtoupper php function will make all words as upper case(capital letter)

[code type=php]

$text = “freeze coders”;

$text1 = strtoupper($text); // Output –  FREEZE CODERS

[/code]

 

strtolower()

strtolower php function will make all words as lower case(capital letter)

[code type=php]

$text = ” FREEZE CODERS”;

$text1 = strtolower($text); // Output –  freeze coders

[/code]

 

ucfirst()

ucfirst php function will make the first letter of a string as uppercase

[code type=php]

$text = “freeze coders”;

$text1 = ucfirst($text); // Output –  Freeze coders

[/code]

 

lcfirst()

lcfirst() php function will return the string’s first letter lowercase

[code type=php]

$text = ” FREEZE CODERS”;

$text1 = lcfirst($text); // Output –  fREEZE CODERS

[/code]

 

Leave a Reply

Your email address will not be published. Required fields are marked *

mildly-anemotropism