0

我有这个表格,但想得到总数。请问我该如何计算这个数组?

...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>
}

例如。$total = 票[][价格] + 票[][费用] * 票[][数量];

4

1 回答 1

0

也许是这样的?

$total = 0;
foreach ($_POST['ticket'] as $ticket) {
  $total += $ticket['price'] + $ticket['fee'] * $ticket['qty'];
}

print $total;
于 2012-05-28T11:10:44.457 回答