获取多维数组的结束值 [英] Get end value of multidimensional array
本文介绍了获取多维数组的结束值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个未定义长度的多维数组,看起来像
I've got an multidimensional array of undefined length that looks like
Array
(
[0] => Array
(
[price] => 75
)
[1] => Array
(
[price] => 90
)
[2] => Array
(
[price] => 95
)
[3] => Array
(
[price] => 130
)
)
如何获取数组中最后一个元素的价格值?
How can I get the value of price of the last element in the array?
干杯
推荐答案
试试这个:$array
是你的输入数组
Try this : $array
is your input array
$arr = end($array);
echo $arr['price'];
使用 PHP 5.4 或更新版本:end($array)['price']
– fab (fab 评论)
EDIT : And with PHP 5.4 or newer: end($array)['price']
– fab (Comment by fab)
这篇关于获取多维数组的结束值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文