PHP:在表单提交中获取复选框值和文本字段值

时间:2018-05-26 08:50:33

标签: php arrays foreach

我正在使用像这样的复选框和texfield构建表单

 $sector = [
        ['name'=>'Electrical','id'=>1],
        ['name'=>'Automobile','id'=>2],
        ['name'=>'Repairing','id'=>3],
        ['name'=>'Blacksmith','id'=>4]
    ]
?>
<?php for each($sector as $value){ ?>
  <input type="checkbox" name="work_experience_sector[]"  value=" <?php echo $value['id'] ?>">
<input type="text" name="work_experience_sector_experience[]" class="form-control border-input">

<?php }?>

我想在表单提交

之后检查类别值以及经验年份
eg:
   category-1 and experience-2
   category-2 and experience-4

我试过这个

 foreach($_POST['work_experience_sector_experience'] as $key=>$value){
         echo 'category'.$_POST['work_experience_sector'][$key].'expe'.$value.'<br>';
     }

但问题是没有按正确顺序获取值

0 个答案:

没有答案