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
Make each word’s first letter as capital letter
$text = "freeze coders";
$text1 = ucwords($text); // Output - Freeze Coders
strtoupper php function will make all words as upper case(capital letter)
$text = "freeze coders";
$text1 = strtoupper($text); // Output - FREEZE CODERS
strtolower php function will make all words as lower case(capital letter)
$text = " FREEZE CODERS";
$text1 = strtolower($text); // Output - freeze coders
ucfirst php function will make the first letter of a string as uppercase
$text = "freeze coders";
$text1 = ucfirst($text); // Output - Freeze coders
lcfirst() php function will return the string’s first letter lowercase
$text = " FREEZE CODERS";
$text1 = lcfirst($text); // Output - fREEZE CODERS
0 comments:
Post a Comment