PHP lcfirst() Function
The lcfirst() function in PHP converts the first character of a string to lowercase if that character is alphabetic.
Syntax
1 2 3 |
lcfirst ( string $str ) |
Parameter
str(required)- This parameter signifies the input string.
Return
This function returns a string with the first character lowercased if that character is alphabetic.
Example 1
1 2 3 4 5 6 7 8 9 10 |
<?php //initializing the string $str= "Hello World!"; echo "Actual string:".$str; echo "\nAter the lcfirst() function..."; // converting the first character of a string to lowercase echo "\nNew String: ".lcfirst($str); ?> |
Output
1 2 3 4 5 |
Actual string:Hello World! Ater the lcfirst() function... New String: hello World! |
Example 2
1 2 3 4 5 6 7 8 9 10 11 |
<?php // specifying the array $array = array('This','is','a','PHP','Join','Function'); // returning a string from the elements of the given array. $str= join(" ",$array); echo "Ater the lcfirst() function..."; // converting the first character of a string to lowercase echo "\n".lcfirst($str); ?> |
Output
1 2 3 4 |
Ater the lcfirst() function... this is a PHP Join Function |
Example 3
1 2 3 4 5 6 7 8 9 10 11 |
<?php // specifying the array $array = array('1','2','3','4','5','6'); // returning a string from the elements of the given array. $str= join(" ",$array); echo "Ater the lcfirst() function..."; // converting the first character of a string to lowercase echo "\n".lcfirst($str); // no effect if the string is integer ?> |
Output
1 2 3 4 |
Ater the lcfirst() function... 1 2 3 4 5 6 |