php循环添加数据时遇到的坑

        foreach ($permissions as $key=>$val){
            $resKey = $val['system_short_name']."-".$val['model_short_name'];
            $res[$resKey]['system_short_name'] = $val['system_short_name'];
            $res[$resKey]['model_short_name'] = $val['model_short_name'];
            foreach ($type as $k=>$v){
                //此处不加判断的话会不断的覆盖下面添加的结果
                if (!isset($res[$resKey][$v['look_up_val']])){
                    $res[$resKey][$v['look_up_val']] = ['disable'=>1];
                }
                if($val['function_type'] == $v['id']){
                    $res[$resKey][$v['look_up_val']] =  [
                        'disable'=>0,
                        'checked' => 1,
                        'id' => $val['id']
                    ];
                }
            }
        }
posted @ 2019-01-19 16:08  周瑜已被使用  阅读(14)  评论(0)    收藏  举报  来源