获取到一个数组的最后一个项目的引用 [英] Getting a reference to the last item of an array
本文介绍了获取到一个数组的最后一个项目的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以使用以下方法来获得 $阵列
的最后一个项目的价值。我怎样才能获得该项目的引用?
$ 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屋!
查看全文