• array_values打破原有的数组key值,重新从0往上排序


    public function bucket_second() {
        $bucket = $this->workerModel->getBucketWorkerHave($this->uid, $this->shopId);
        $data=array();
        if ($bucket) {
            foreach ($bucket AS $value) {
                $data[$value['goods_id']]['goods_id']=$value['goods_id'];
                $data[$value['goods_id']]['heavy'] +=$value['heavy_num'];
                $data[$value['goods_id']]['light'] += $value['light_num'];
                $data[$value['goods_id']]['sum']   += $value['light_num']+$value['heavy_num'];
            }
        }
        unset($bucket);
        if($data){
            foreach ($data as $k=>$v){
                //var_dump($k);
                $goods_name=model('goods')->getGoodsName($k);
                if(!$goods_name){
                    unset($data[$k]);
                    continue;
                }
    
                $data[$k]['goods_name']=$goods_name;
            }
            $data=array_values($data);
        }
    
    
        return $this->json = array(
            'ret'   => API_OK,
            'response'  => array(
                'list'   => $data
            )
        );
        
        
    }
    array_values

  • 相关阅读:
    文件的初级功能
    Scanner的用法
    界面制作小例
    初学Java感想
    el-table合计栏未显示的问题
    推荐一些团队博客和个人博客地址
    大数加法
    汇编语言画圆
    Java一个简单的文件工具集
    css选择器
  • 原文地址:https://www.cnblogs.com/wanghaitao/p/9440365.html
Copyright © 2020-2023  润新知