How to Use array_pop() Function in PHP

array_pop function pops or removes the last value of an array. It’s used to shorten any array.

Let’s see how this works.

$bands = array('The Beatles', 'The Doors', 'Dire Straits', 'Simon and Garfunkel');
$band = array_pop($bands);
print_r($bands);

Output will look like this :

Array ( [0] => The Beatles [1] => The Doors [2] => Dire Straits )

Here array_pop() function removed the last value of the array.

Click Here to Leave a Comment Below

Leave a Reply: