我想获取' $ quantity'的数据。数组没有重复前面的索引值。在下面的代码中有一个重复的索引前值
$sql="select
tou.retailer_code,tou.retailer_name, tso.added_date,tso.sales_order_code,tsohfi.id_sales_order
from
tbl_sales_order_has_free_item tsohfi
inner join
tbl_sales_order tso on
tsohfi.id_sales_order=tso.id_sales_order
inner join
tbl_outlet_has_route tohr on
tso.id_outlet_has_route=tohr.id_outlet_has_route
inner join
tbl_outlet tou on
tou.id_outlet=tohr.outlet_id
inner join
tbl_product tp on
tp.product_id=tsohfi.product_id
where tso.status=1 {$root}{$sales_date}
group by tsohfi.id_sales_order
";
$free_sql = $this->db->mod_select($sql);
foreach($free_sql as $value){
$sql2="select
product_id,qty
from
tbl_sales_order_has_free_item
where id_sales_order= $value->id_sales_order";
$quantity_sql=$this->db->mod_select($sql2);
foreach ($quantity_sql as $row)
{
$quantity[] = array(
'product_id' => $row->product_id,
'quantity' => $row->qty
);
}
$item_array[]=array(
'retailer_code' => $value->retailer_code,
'retailer_name' => $value->retailer_name,
'added_date' => $value->added_date,
'sales_order_code'=>$value->sales_order_code,
'id_sales_order'=>$value->id_sales_order,
'quantity'=>$quantity
);
}
return $item_array;
重复循环的输出 我想得到[0]值1st和1值第二和[2]值在第三等