php 二維數組 根據條件合並成新的二維數組
阿新 • • 發佈:2018-05-15
ID info 二維 HP 合並 goods sta AR 根據
$_data = []; $order_id = ‘‘; foreach ($data as $k => $v) { if($order_id != $v[‘order_id‘]){ $arr = []; $arr[‘id‘] = $v[‘id‘]; $arr[‘order_number‘] = $v[‘order_number‘]; $arr[‘edit_time‘] = $v[‘edit_time‘];$arr[‘order_state‘] = $v[‘order_state‘]; $arr[‘goods_info‘][] = $v; $_data[] = $arr; $order_id = $v[‘order_id‘]; }else{ $arr = $_data[sizeof($_data)-1]; $arr["goods_info"][] = $v; $_data[sizeof($_data)-1] = $arr; } }
php 二維數組 根據條件合並成新的二維數組