How to loop through json Object using foreach using PHP?

后端 未结 2 532
小蘑菇
小蘑菇 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条回答
  •  攒了一身酷
    2021-01-29 09:31

    You are supplying the wrong index in this code

    foreach($this->jsonObj->{'participants'} as $index => $value)
    {
        // $this->html.='' . $this->jsonObj->participants[$value].' ';
    
        // instead
        $this->html.='' . $this->jsonObj->participants[$index].' ';
    
        //or
        //$this->html.='' . $value.' ';
    
    } // foreach
    

提交回复
热议问题