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

end

Description

The end of Array for PHP sets the internal pointer of an array to its last element.

Syntax

end(
    array|object &$array
): mixed

Parameters

array

The array. This array is passed by reference because it is modified by the function. This means you must pass it a real variable and not a function returning an array because only actual variables may be passed by reference.

Return

Returns the value of the last element or false for empty array.

Examples

1 · end

<?

$array =
[
    0,
    1,
    2
];

$return = end($array);

echo $return;
2

2 · empty

<?

$array = [];

$return = end($array);

var_export($return);
false

3 · order

<?

$array = [];
$array[0] = 0;
$array[1] = 1;
$array[2] = 2;

$return = end($array);

echo $return;
2

4 · order

<?

$array = [];
$array[2] = 2;
$array[1] = 1;
$array[0] = 0;

$return = end($array);

echo $return;
0