PHP 8.5.0 RC 2 available for testing

array_last

(PHP 8 >= 8.5.0)

array_lastGets the last value of an array

说明

array_last(array $array): mixed

Get the last value of the given array.

参数

array

An array.

返回值

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

示例

示例 #1 Basic array_last() Usage

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

$lastValue = array_last($array);

var_dump($lastValue);
?>

以上示例会输出:

string(1) "d"

参见

添加备注

用户贡献的备注

此页面尚无用户贡献的备注。
To Top