The string functions lcfirst() and ucfirst() are used in the cases when there is a need for manipulating your string first alphabet. These occurs when the string is like name or title.
lcfirst()
This function does the lowering of the first alphabet of the string. this function is used to lower the first alphabet of the string.
for example:
<?php
$str = "ayush";
$name = ucwords($str);
echo $name;
?>
output
Ayush
ucfirst()
This function does the opposite of the lcfirst() function as it change the first alphabet of the string in the upper case. this function is used to upper case the first alphabet of the string.
<?php
$str = "what is the length of the string?";
$str2 = ucfirst($str);
echo $str2;
?>
output
What is the length of the string?
0 Comment(s)