update page now

array_last

(PHP 8 >= 8.5.0)

array_lastGets the last value of an array

Description

array_last(array $array): mixed

Get the last value of the given array.

Parameters

array
An array.

Return Values

Returns the last value of array if the array is not empty; null otherwise.

Examples

Example #1 Basic array_last() Usage

<?php
$array
= [1 => 'a', 0 => 'b', 3 => 'c', 2 => 'd'];

$lastValue = array_last($array);

var_dump($lastValue);
?>

The above example will output:

string(1) "d"

See Also

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant