Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to delete last element in an array

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 248
    Comment on it

    Hello Readers ,

    If we have an array and we want to delete the last record in an array then their is a function called array_pop() .

    The array_pop() function deletes the last element of an array.

    Example :

    <?php
    $a=array("red","green","blue");
    array_pop($a);
    print_r($a);
    ?>
    

    Output :

     Array ( [0] => red [1] => green ) 
    

    Here from above you will see the last element i.e. "blue" has been deleted from the array while using array_pop().

 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: