我希望使用不同的电子邮件一次保存多个报告。 以下是我的代码:
<tr>
<td>
<h4>Select Report</h4>
<input type = 'checkbox' name = 'reports[]' value = 'daily sales report' /> Daily Sales Report <br />
<input type = 'checkbox' name = 'reports[]' value = 'department sales report' /> Department Sales Report <br />
<input type = 'checkbox' name = 'reports[]' value = 'hourly sales report' /> Hourly Sales Report <br />
<input type = 'checkbox' name = 'reports[]' value = 'hourly sales summary report' /> Hourly Sales Summary Report <br />
<input type = 'checkbox' name = 'reports[]' value = 'inventory report' /> Inventory Report <br />
</td>
</tr>
它将在下面生成一个数组:
[reports] => Array
(
[0] => daily sales report
[1] => department sales report
[2] => hourly sales report
[3] => hourly sales summary report
[4] => inventory report
)
我的问题是想在表中添加另一行后创建一个报表数组。我想生成如下数组:
[reports] => Array
(
[0] => Array
(
[0] => daily sales report
[1] => department sales report
[2] => hourly sales report
[3] => hourly sales summary report
[4] => inventory report
)
[1] => Array
(
[0] => daily sales report
[1] => department sales report
[2] => hourly sales report
[3] => hourly sales summary report
[4] => inventory report
)
)
答案 0 :(得分:0)
试试这个:
if(isset($_POST)){
if(empty($reports)){
$reports[]=$_POST;
}else{
array_push($reports,$_POST);
}
}