Skip to content

Latest commit

 

History

History
45 lines (29 loc) · 520 Bytes

array_last.md

File metadata and controls

45 lines (29 loc) · 520 Bytes

Description

Get the last item from an array

array_last(array $array): mixed

Parameters

array

The input array

Returns

The last item in the array or null for an empty array

Examples

Example # 1 Example uses of array_last() with an empty array

$array = [];
echo array_last($array);

The above example will output:

null

Example # 2 an array with items

$array = ['a' => 1, 2, 3];
echo array_last($array);

The above example will output:

3