Loading…

What is the difference between array_pop() and array_push()?

array_pop() : It is used to delete or remove the last element of an array.

$a=array("blue","black","skyblue");
array_pop($a);

OUTPUT : Array ( [0] => blue[1] => black)

array_push() : It is used to Insert one or more elements to the end of an array.

$a=array("apple","banana"); array_push($a,"mango","pineapple");

OUTPUT : Array ( [0] => apple[1] => banana[2] => mango[3] => pineapple)

Suggest An Answer

No suggestions avaliable!

Latest post from PHP Arrays

Ask Question