array_push() –php array function

Explanation

The “array_push” function is used insert one or more elements onto the end of array.

Syntax:

    array_push(array,value1,value2...)

In the above syntax “array” specifies the array to which the values in “value1” is to be added, “value2” is optional.

Example

    <?php
    $b=array("c"=>"Cherry","b"=>"Strawberry");
    print_r(array_push($b, Orange, Guava));
    ?>

Result:

    Array ( [c]=> Cherry,[b]=> Strawberry, [0]=> Orange, [1]=> Guava);

In the above example even though the array already has string keys, the added elements will have numerical keys.