HomeMenu
Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

array_pop

Description

The array_pop of Array for PHP pops the element off the end of array.

Syntax

array_pop(
    array &$array
): mixed

Parameters

array

The array to get the value from.

Return

Returns the value of the last element of array. If array is empty, null will be returned.

Examples

1 · array

<?

$array =
[
    "apple",
    "banana",
    "coconut"
];

array_pop($array);

print_r($array);
Array
(
    [0] => apple
    [1] => banana
)

2 · return · last

<?

$array =
[
    "apple",
    "banana",
    "coconut"
];

$return = array_pop($array);

print_r($return);
coconut

3 · return · empty

<?

$array = [];

$return = array_pop($array);

var_export($return);
NULL