如何在PHP中的特定索引处启动foreach循环
问题描述:
我正在写一个foreach
,它不是从第0个索引开始,而是从数组的第一个索引开始.有什么办法可以抵消循环的起点吗?
I am writing a foreach
that does not start at the 0th index but instead starts at the first index of my array. Is there any way to offset the loop's starting point?
答
保持简单.
foreach ($arr as $k => $v) {
if ($k < 1) continue;
// your code here.
}
请参见手册中的 continue
控制结构.
See the continue
control structure in the manual.