thinkPHP多层json遍历

热门标签

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']);
//输出
        
    }

特别声明:文章多为网络转载,资源使用一般不提供任何帮助,特殊资源除外,如有侵权请联系!

评论 (0)