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

后端 未结 12 1366
情歌与酒
情歌与酒 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:51

    if you structure your form differently

      
      
    

    ...then in your PHP

    if( isset($_POST['quiz']) AND 
        is_array($_POST['quiz'])) {
    
        //...and we'll skip $_POST['quiz']['first'] 
        foreach($_POST['quiz'] as $key => $val){
          if($key == "first") continue;
          print $val; 
        }
    }
    

    ...you can now just loop over that particular structure and access rest normally

提交回复
热议问题