获取到一个数组的最后一个项目的引用 [英] Getting a reference to the last item of an array

查看:94
本文介绍了获取到一个数组的最后一个项目的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用以下方法来获得 $阵列的最后一个项目的价值。我怎样才能获得该项目的引用?

  $ LAST_ITEM =结束($数组);

$阵列的项目索引数组。


解决方案

 端($数组);
$ referenceToLastElement =安培; $阵列[关键($数组)];

I can use the following to get the value of the last item of $array. How can I get a reference to that item?

$last_item = end($array);

The items of $array are indexed arrays.

解决方案

end($array);
$referenceToLastElement = &$array[key($array)];

这篇关于获取到一个数组的最后一个项目的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆