Php Array Elements Insert/ Push Function

What is array_push Function?


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



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

Example :

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.

PHP Topics

Ask Questions

Ask Question