PHP-按索引范围获取数组记录 [英] PHP - get array records by index range

查看:307
本文介绍了PHP-按索引范围获取数组记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何PHP本机函数根据索引的开始和结束从数组返回记录范围?

Is there any PHP native function which returns the range of records from the array based on the start and end of the index?

即:

array(0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd');

现在我只想返回索引1和3之间的记录(b,c,d) 。

and now I would like to only return records between index 1 and 3 (b, c, d).

有什么想法吗?

推荐答案

您不能那样做吗?与例如 array_slice

Couldn't you do that with e.g. array_slice?

$a = array(0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd');
array_slice($a, 1, 3); 

这篇关于PHP-按索引范围获取数组记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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