我想用不同的电子邮件一次保存多个报告。以下是我的代码:
<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
)
)
试试这个:
if(isset($_POST)){
if(empty($reports)){
$reports[]=$_POST;
}else{
array_push($reports,$_POST);
}
}