Get the last item from an array
array_last(array $array): mixed
array
The input array
The last item in the array or null for an empty array
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