TP5二维数组分类重组

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_36020968/article/details/85261309

上传之前的数组格式list

foreach($voucherInfo as $key=>$vo){
            $list[] = array_merge($vo,$voucherTypeInfo[$key]);
        }
           
        foreach ($list as $voucher){
            $temp['id'] = $voucher['voucher_id'];
            $temp['title'] = $voucher['title'];
            $temp['price'] = $voucher['price'];
            $temp['jifen'] = ceil(bcdiv(bcmul($voucher['price'],10000),15,2));
            $temp['is_show'] = $voucher['is_show'];
            $temp['icon'] = $voucher['img'];
            $data[$voucher['name']][] = $temp;
        }
        return $data;

重组以后的data数组

通过name值对数组重组成多组二维数组

猜你喜欢

转载自blog.csdn.net/qq_36020968/article/details/85261309