How do I loop through JSON array

后端 未结 2 1111
鱼传尺愫
鱼传尺愫 2020-12-02 21:01

How do I traverse and display the names in the following JSON using CodeIgniter?



        
2条回答
  •  抹茶落季
    2020-12-02 21:22

    1) $json is a string you need to decode it first.

    $json = json_decode($json);
    

    2) you need to loop through the object and get its members

    foreach($json as $obj){
       echo $obj->name;
       .....
    
    }
    

提交回复
热议问题