tp5数组操作问题求解

浏览:3164 发布日期:2017/01/03 分类:求助交流
$arr = [

            '6d7470ef' =>[
                'shop_id'=>'1',
                'total'=>'30',
                'num'=>'1',
            ],
            'd2f87737' =>[
                'shop_id'=>'1',
                'total'=>'60',
                'num'=>'2',
            ],
            '255211b6' =>[
                'shop_id'=>'2',
                'total'=>'30',
                'num'=>'1',
            ],
            '1d707990' =>[
                'shop_id'=>'2',
                'total'=>'90',
                'num'=>'3',
            ],
        ];
        $a = [];
        foreach($arr as $k=>$vo){
            $a[$vo['shop_id']][] = $vo;
            $a[$vo['shop_id']]['shopnum'] += $vo['num'];
        }
        echo '<pre>';
        print_r($a);
代码如上,在tp5框架里操作提示错误
未定义数组索引: shopnum

不使用框架执行没有问题
最佳答案
评论( 相关
后面还有条评论,点击查看>>