如何跳过数组循环中的第一个键? [英] How to skip the 1st key in an array loop?
本文介绍了如何跳过数组循环中的第一个键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码:
if ($_POST['submit'] == "Next") {
foreach($_POST['info'] as $key => $value) {
echo $value;
}
}
如何让 foreach 函数从数组中的第二个键开始?
How do I get the foreach function to start from the 2nd key in the array?
推荐答案
对于相当小的数组,使用 array_slice 创建第二个:
For reasonably small arrays, use array_slice to create a second one:
foreach(array_slice($_POST['info'],1) as $key=>$value)
{
echo $value;
}
这篇关于如何跳过数组循环中的第一个键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文