Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/236.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP Post多复选框集数组_Php_Html_Arrays_Post_Checkbox - Fatal编程技术网

PHP Post多复选框集数组

PHP Post多复选框集数组,php,html,arrays,post,checkbox,Php,Html,Arrays,Post,Checkbox,我有一个包含多个复选框集的表单,其中输入的名称是动态创建的(name=“”.$name.[])。HTML结果如下所示: <tr> <td><input type="checkbox" name="1[]" value="Jan"/></td> <td><input type="checkbox" name="1[]" value="Feb"/></td> </tr> <tr> <td

我有一个包含多个复选框集的表单,其中输入的名称是动态创建的(name=“”.$name.[])。HTML结果如下所示:

<tr>
<td><input type="checkbox" name="1[]" value="Jan"/></td>
<td><input type="checkbox" name="1[]" value="Feb"/></td>
</tr>
<tr>
<td><input type="checkbox" name="2[]" value="Jul"/></td>
<td><input type="checkbox" name="2[]" value="Sep"/></td>
<td><input type="checkbox" name="2[]" value="Dec"/></td>
</tr>
<tr>
<td><input type="checkbox" name="3[]" value="May"/></td>
<td><input type="checkbox" name="3[]" value="Aug"/></td>
</tr>
我需要输入名称作为任务ID:

Task ID is: 1 and the month check is Jan
Task ID is: 1 and the month check is Feb
Task ID is: 2 and the month check is Jul
Task ID is: 2 and the month check is Sep
Task ID is: 2 and the month check is Dec
Task ID is: 3 and the month check is May
Task ID is: 3 and the month check is Aug

感谢您在advanced中提供的任何帮助。

您的$\u帖子将以表单帖子名称作为关键字。因此,您必须从第一个foreach循环获取密钥,如下所示:

foreach ($_POST as $task_name => $task){
    foreach ($task as $key => $month){
        echo '<p>Task ID is: '. $task_name .' and the month check is '. $month .'';
    }       
}
foreach($\u发布为$task\u name=>$task){
foreach($key=>$month的任务){
echo“任务ID为:”.$Task_name.”,月份检查为“$month.”;
}       
}

您的$\u帖子将以表单帖子名称作为关键字。因此,您必须从第一个foreach循环获取密钥,如下所示:

foreach ($_POST as $task_name => $task){
    foreach ($task as $key => $month){
        echo '<p>Task ID is: '. $task_name .' and the month check is '. $month .'';
    }       
}
foreach($\u发布为$task\u name=>$task){
foreach($key=>$month的任务){
echo“任务ID为:”.$Task_name.”,月份检查为“$month.”;
}       
}

谢谢!我想我也试过了,但我一定错过了什么。谢谢!我以为我也试过那样做,但我肯定错过了什么。
foreach ($_POST as $task_name => $task){
    foreach ($task as $key => $month){
        echo '<p>Task ID is: '. $task_name .' and the month check is '. $month .'';
    }       
}