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.


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)

Also Read: PHP Strings

Suggest An Answer

No suggestions avaliable!

Latest post from PHP Arrays

Ask Question