hyster Posted February 14, 2016 Share Posted February 14, 2016 I have a json data set that I'm trying to loop and echo but part of the dataset changes for each set of data. I'm stuck on the $data,[????][name_il8n] . how do I loop the part with the ???? when I just need the [name_il8n] data ?? sample of the dataset "status": "ok", "meta": { "count": 43 }, "data": { "92_stalingrad": { "name_i18n": "Stalingrad" }, "36_fishing_bay": { "name_i18n": "Fisherman's Bay" }, "05_prohorovka": { "name_i18n": "Prokhorovka" }, "101_dday": { "name_i18n": "Overlord" }, } code so far $jsonurl = "https://api.worldoftanks.eu/wot/encyclopedia/arenas/?application_id$app_id"; $json = file_get_contents($jsonurl,0,null,null); $output = json_decode($json, true); foreach ($output['data']['????']['name_i18n'] as $item){ echo "<option>".$item['name_i18n']."</option>"; } thanks for any help Quote Link to comment https://forums.phpfreaks.com/topic/300808-json-decode-with-foreach/ Share on other sites More sharing options...
Solution requinix Posted February 14, 2016 Solution Share Posted February 14, 2016 foreach ($output['data'] as $item){ Quote Link to comment https://forums.phpfreaks.com/topic/300808-json-decode-with-foreach/#findComment-1531096 Share on other sites More sharing options...
hyster Posted February 14, 2016 Author Share Posted February 14, 2016 thanks requinix I found my problem, I was missing a = in the url :$ Quote Link to comment https://forums.phpfreaks.com/topic/300808-json-decode-with-foreach/#findComment-1531098 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.