How to skip the 1st key in an array loop?

后端 未结 12 1367
情歌与酒
情歌与酒 2020-12-03 04:29

I have the following code:

if ($_POST[\'submit\'] == \"Next\") {
    foreach($_POST[\'info\'] as $key => $value) {
        echo $value;
    }
}

12条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-03 04:54

    If you're willing to throw the first element away, you can use array_shift(). However, this is slow on a huge array. A faster operation would be

    reset($a);
    unset(key($a));
    

提交回复
热议问题