DeTechn Blog

thinkPHP多层json遍历

<?
public function demodel(){
      $arr = 2;
      $list=Db::name('goods')->where('id',1)->field('goods')->find();
      $list['goods'] = json_decode($list['goods'],true);

      foreach($list['goods']  as $key => $value){
            foreach($value['spec_list'] as $ke => $val){
                if($list['goods'][$key]['spec_list'][$ke]['spec_sku_id'] == '2_7'){
                    $list['goods'][$key]['spec_list'][$ke]['form']['price'] = $arr;
                }
            }
      }
        print_r($list['goods']);
//输出
        
    }

当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »