[英]How can I get the last value of an array?
Below are the contents of the array. 以下是数组的内容。 How can I get the last array,
[cat_name] => Lcd
? 如何获得最后一个数组
[cat_name] => Lcd
?
I do not need: 我不需要:
[cat_link] => lcd
[cat_id] => 172
(
[0] => Array
(
[cat_name] => Electronics
[cat_link] => electronics
[cat_id] => 164
)
[1] => Array
(
[cat_name] => Televisions
[cat_link] => televisions
[cat_id] => 165
)
[2] => Array
(
[cat_name] => Lcd
[cat_link] => lcd
[cat_id] => 172
)
)
您可以像这样检索数组的最后一个元素: $array[count($array) - 1]
您可以这样获得最后一个cat_name
值:
$arr[count($arr) - 1]['cat_name']
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.