我有这个表格,但想得到总数。 请问我该如何计算这个数组?
...While(ticket table row)
{
<input type="text" name="ticket[][price]" id="ticket[][price]" value="12">
<input type="text" name="ticket[][fee]" id="ticket[][fee]" value="3462">
<select name="ticket[][qty]">
<option value="1">1
<option value="2">2
<option value="3">3
<option value="4">4
<option value="5">5
<option value="6">6
</select>
}
EG。 $ total = ticket [] [price] + ticket [] [费用] * ticket [] [qty];
答案 0 :(得分:0)
也许是这样的?
$total = 0;
foreach ($_POST['ticket'] as $ticket) {
$total += $ticket['price'] + $ticket['fee'] * $ticket['qty'];
}
print $total;