How to loop through json Object using foreach using PHP?

后端 未结 2 505
小蘑菇
小蘑菇 2021-01-29 08:47

How do I use for each to access and print the participant name. The Json object is \"particpants:name\" and it gets populated when uploaded with a tokenized file. I know the tok

2条回答
  •  梦毁少年i
    2021-01-29 09:25

    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;
       .....
    
    }
    

提交回复
热议问题