二个foeache 实现数据的递归
作者:互联网
$type =Db::name('shop_goods_spu_specification')//查询商品规格维度
->field('id,parent_id,title')
->where('spu_id',$goods_id)
->select();
$type1=Db::name('shop_goods_spu_specification_sub')//查询商品规格维度详情
->field('id,spec_id,title')
->where('id','in',$arr)
->select();
//dump($arr);die();
$arr=[];//处理数据进行组合数组进行返回
foreach ($type1 as &$v){
$arr[$v['spec_id']][]=$v;
}
foreach ($type as &$value){
$value['son']=$arr[$value['id']];
}
// dump($type);die();
return $type; //返回数据
标签:arr,goods,递归,foeache,二个,spu,value,type,id 来源: https://www.cnblogs.com/huliangqing/p/14771716.html