php - foreach loop returns multiple copies of the same entry -
im trying list each 'name' entry json file. keep getting same entry copied few times each parent. example 'name' returns dennisdennisdennisdennis. cant remove [3] (or number inside it) because page turn blank. how code next time lists each of names in json? code:
$opts = array( 'http'=>array( 'header'=>"x-auth-token: 41e509ad68f0......" ) ); $context = stream_context_create($opts); $url = 'workingurlhere'; $data = file_get_contents($url, true, $context); $result = json_decode($data); foreach ($result $all){ echo $result -> data[3] -> name; } ?>
you need reference $all not $result.
foreach ($result $all){ echo $all -> data[3] -> name; }
Comments
Post a Comment