Clinsta Posted August 1, 2015 Share Posted August 1, 2015 So i currently have this code(Linked in Pastebin link) attempting to pull multiple arrays but having no luck and wondering if i could get a hand. The Json file example will be linked as well as the php. PHP - http://pastebin.com/FRuGdXyi JSON - http://pastebin.com/d1iVkiN3 The total_count can be different depending on the user as well as the array info. Quote Link to comment Share on other sites More sharing options...
Clinsta Posted August 1, 2015 Author Share Posted August 1, 2015 Sorry mistype of json file link is http://pastebin.com/uMqjQqRd Quote Link to comment Share on other sites More sharing options...
scootstah Posted August 2, 2015 Share Posted August 2, 2015 ['total_count'] ['%'] ['games'] ['name'];Where did you come up with this syntax? What do you think this is doing? Quote Link to comment Share on other sites More sharing options...
Clinsta Posted August 2, 2015 Author Share Posted August 2, 2015 That's how i was shown to pull info from json, it works with another api that i am using but the ['%'] was a placeholder because that number can vary depending on user. it follows the steps of the array. Here is an example of it working. http://pastebin.com/GQZ97AvB / http://pastebin.com/9bCEYmzE / http://gyazo.com/0542954b90d9a7d7858c4f0c00914ec5.png Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted August 2, 2015 Share Posted August 2, 2015 $gameQuery['response'] ['total_count'] will only return the total count from here "total_count": 4, which is four To get the games you want to use $gameQuery['response'] ['games'], Preferably use a foreach loop to iterate over each game. Example $gameQuery = json_decode($gameInfo, true); echo "Total Games: " . $gameQuery['response'] ['total_count'] . "<br />\nThese are:<br />\n"; foreach($gameQuery['response']['games'] as $gameInfo) { // playtime_forever returns total time game has been played in minutes, // divided by 3600 to convert to hours $hoursPlayed = ceil($gameInfo['playtime_forever'] / 3600); echo "<p><b>" . $gameInfo['name'] . "</b> - Hours played: $hoursPlayed</p>\n"; } Quote Link to comment 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.