Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/297578-php-pulling-only-json-file-info/
Share on other sites

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

$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";
}
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.