如何让一个PHP数组作为另一个数组的最后一个n项? [英] How to get the last n items in a PHP array as another array?
本文介绍了如何让一个PHP数组作为另一个数组的最后一个n项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何,我得到另一个数组的最后n个元素的数组中的PHP?
How to I get an array of the last n items of another array in PHP?
推荐答案
$ N
等于你要离开结束项目的数量。
$n
is equal to the number of items you want off the end.
$arr = array_slice($old_arr, -$n);
这篇关于如何让一个PHP数组作为另一个数组的最后一个n项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文