Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • lcfirst() and ucfirst() string functions in php

    • 0
    • 2
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 259
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: