Menu Close

How to convert a first character of a string into lowercase in PHP?

lcfirst

The lcfirst() is in-built PHP string function. It is used to convert the first character of a string to lowercase. In another words we can say that it make a string’s first character lowercase. It returns the converted string.

Hint: Use the PHP lcfirst() function

Syntax

lcfirst($string) 

Parameters

$string (required): This is a mandatory parameter of this function which specifies a first character of a string into lowercase.

Return Value

It returns converted first character of a string into lowercase.

Example

You can use the PHP lcfirst() function to convert a first character of a string into lowercase. Let’s check out the following example to understand how this function actually works:
<?php
$my_str = 'LEARN, SHARE AND GROW YOUR CODING SKILLS';
echo lcfirst($my_str);
?> 

Output

lEARN, SHARE AND GROW YOUR CODING SKILLS 

There are some other functions in PHP which are similar to the lcfirst() function:

Related PHP functions

  • strtolower() – It converts a string into lowercase.
  • strtoupper() – It converts a string into uppercase.
  • ucfirst() – It converts the first character of a string into uppercase.
  • ucwords() – It converts the first character of each word in a string into uppercase.
Posted in PHP

You can also read...