Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to insert more values in an array in PHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 227
    Comment on it

    Hello Readers ,

    If we want to insert more records at the end of an array then their is function called array_push() that we can use.

    Example :

    If we have an existing array array("red","green"); and we want to insert two more values at the end of this array then you can use the below code.

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

    Output:

     Array ( [0] => red [1] => green [2] => blue [3] => yellow ) 
    

 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: