0

我想做的是一个条件为unchecked。复选框。只有选中的(复选框)可以用于循环。如果未选中复选框,如何停止 foreach 运行?

样本循环。

   $count = count($waybillno);

   for ($i = 0; $i < $count; $i++) {

            $data = array(
                'waybillno' => $waybillno[$i],
                'quantity' => $quantity[$i],
                'waybilldate' => $waybilldate[$i],
                'declared_value' => $declared_value[$i],
                'consignee' => $consignee[$i],

            );
4

1 回答 1

0

编辑
尝试:

$count = (count($waybillno));
for ( $i = 0; $i < $count; $i++ ) {
    if( isset( $waybillno[$i] ) && $waybillno[$i] != "" ){
        $data = array(
        'waybillno' => $waybillno[$i],
        'quantity' => $quantity[$i],
        'waybilldate' => $waybilldate[$i],
        'declared_value' => $declared_value[$i],
        'consignee' => $consignee[$i],
        );
        #update query here   
    }
}
于 2013-08-23T07:26:26.170 回答