Name

array_pop()

Synopsis

    mixed array_pop ( array &arr )

The array_pop() function takes an array as its only parameter, and returns the value from the end of the array while also removing it from the array. For example:

    $names = array("Timmy", "Bobby", "Sam", "Tammy", "Joe");
    $firstname = array_pop($names);
    // first is Timmy; last is Joe again

Get PHP in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.