Parsing JSON array with PHP foreach

后端 未结 3 734
广开言路
广开言路 2020-11-29 04:09

Wondering why my PHP code will not display all \"Value\" of \"Values\" in the JSON data:

$user = json_decode(file_get_contents($analytics));
foreach($user-&g         


        
3条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-29 04:49

    You maybe wanted to do the following:

    foreach($user->data as $mydata)
    
        {
             echo $mydata->name . "\n";
             foreach($mydata->values as $values)
             {
                  echo $values->value . "\n";
             }
        }        
    

提交回复
热议问题