开发者

Retrieve an array?

I'm trying to get an array for a particular player.

Code so far:

<?php

//incude sql database connection
include_once('sql.php');
//include api key 
include_once('api.php');

$gameId = "448434948";
$gamertag = "Jam1efoster";

$GetGameDetails = "http://www.bungie.net/api/reach/reachapijson.svc/game/details/".$apiKey."/".$gameId;

$output = file_get_contents($GetGameDetails);
$obj = json_decode($output);
//echo $output."<br/>";

foreach($obj->GameDetails->Players as $players) {
    foreach($players->SpecificMedalCounts as $SpecificMedalCounts) {
        $medal = $SpecificMedalCounts;
        echo '<pre>'.print_r($medal,1).'</pre>';
    }
}
?>

Here is the $output before it is decoded

{"reason":"Okay","status":0,"GameDetails":{"BaseMapName":"Reflection","CampaignDifficulty":"Easy","CampaignGlobalScore":0,"CampaignMetagameEnabled":false,"GameDuration":373,"GameId":448434948,"GameTimestamp":"\/Date(1295993863040-0800)\/","GameVariantClass":3,"GameVariantHash":-1559817880631004487,"GameVariantIconIndex":1,"GameVariantName":"SWAT","HasDetails":true,"IsTeamGame":true,"MapName":"Reflection","MapVariantHash":-5431616218904750125,"PlayerCount":8,"Players":[

{"AiEventAggregates":[],"Assists":0,"AvgDeathDistanceMeters":26.3847733,"AvgKillDistanceMeters":27.7626762,"Betrayals":0,"DNF":false,"Deaths":11,"DeathsOverTime":[[0,0],[22,1],[61,2],[93,3],[101,4],[119,5],[176,6],[191,7],[281,8],[305,9],[340,10],[367,11],[373,11]],"Headshots":14,"IndividualStandingWithNoRegardForTeams":0,"IsGuest":false,"KilledMostByCount":5,"KilledMostCount":5,"Kills":16,"KillsOverTime":[[0,0],[31,1],[55,2],[75,3],[79,4],[80,5],[93,6],[136,7],[142,8],[145,9],[152,10],[168,11],[170,12],[190,13],[214,14],[256,15],[300,16],[373,16]],"MedalsOverTime":[[0,0],[31,1],[55,2],[75,3],[80,4],[80,5],[93,6],[136,7],[142,8],[145,9],[145,10],[152,11],[152,12],[168,13],[168,14],[170,15],[170,16],[190,17],[214,18],[256,19],[300,20],[373,20]],"MultiMedalCount":3,"OtherMedalCount":0,"PlayerDataIndex":6,"PlayerDetail":{"CampaignProgressCoop":"PartialNormal","CampaignProgressSp":"None","Initialized":true,"IsGuest":false,"LastGameVariantClassPlayed":"Competitive","ReachEmblem":{"background_index":20,"change_colors":[0,0,0,2],"flags":0,"foreground_index":65},"armor_completion_percentage":0.307189554,"daily_challenges_completed":111,"first_active":"\/Date(1284443880000-0700)\/","gamertag":"Venomous Karnij","games_total":544,"last_active":"\/Date(1298086260000-0800)\/","service_tag":"JMAN","weekly_challenges_completed":2},"PlayerKilledByMost":"Yrmt1964","PlayerKilledMost":"Yrmt1964","PointsOverTime":[[0,0],[373,0]],"Rating":0,"Score":16,"SpecificMedalCounts":[

{"Key":117,"Value":1},{"Key":11,"Value":1},{"Key":2,"Value":3},{"Key":85,"Value":14},{"Key":95,"Value":1},{"Key":104,"Value":1}

],"SpreeMedalCount":1,"Standing":0,"StyleMedalCount":17,"Suicides":0,"Team":1,"TeamScore":50,"TotalMedalCount":21,"UniqueMultiMedalCount":1,"UniqueOtherMedalCount":0,"UniqueSpreeMedalCount":1,"UniqueStyleMedalCount":4,"UniqueTota开发者_运维技巧lMedalCount":6,"WeaponCarnageReport":[{"Deaths":11,"Headshots":14,"Kills":15,"Penalties":0,"WeaponId":6},{"Deaths":0,"Headshots":0,"Kills":1,"Penalties":0,"WeaponId":43}]},

{"AiEventAggregates":[],"Assists":0,"AvgDeathDistanceMeters":31.5024147,"AvgKillDistanceMeters":24.3540745,"Betrayals":0,"DNF":false,"Deaths":9,"DeathsOverTime":[[0,0],[17,1],[32,2],[94,3],[130,4],[167,5],[181,6],[202,7],[283,8],[361,9],[373,9]],"Headshots":8,"IndividualStandingWithNoRegardForTeams":3,"IsGuest":false,"KilledMostByCount":4,"KilledMostCount":3,"Kills":8,"KillsOverTime":[[0,0],[28,1],[103,2],[163,3],[243,4],[260,5],[263,6],[300,7],[328,8],[373,8]],"MedalsOverTime":[[0,0],[29,1],[103,2],[103,3],[163,4],[243,5],[260,6],[263,7],[263,8],[300,9],[328,10],[373,10]],"MultiMedalCount":1,"OtherMedalCount":0,"PlayerDataIndex":7,"PlayerDetail":{"CampaignProgressCoop":"PartialNormal","CampaignProgressSp":"CompletedLegendary","Initialized":true,"IsGuest":false,"LastGameVariantClassPlayed":"Competitive","ReachEmblem":{"background_index":35,"change_colors":[9,2,26,17],"flags":1,"foreground_index":0},"armor_completion_percentage":0.457516342,"daily_challenges_completed":89,"first_active":"\/Date(1284438000000-0700)\/","gamertag":"Jam1efoster","games_total":624,"last_active":"\/Date(1295993880000-0800)\/","service_tag":"J","weekly_challenges_completed":4},"PlayerKilledByMost":"TETZ21","PlayerKilledMost":"Yrmt1964","PointsOverTime":[[0,0],[373,0]],"Rating":0,"Score":8,"SpecificMedalCounts":[{"Key":117,"Value":1},{"Key":2,"Value":1},{"Key":85,"Value":8},{"Key":101,"Value":1}],"SpreeMedalCount":0,"Standing":0,"StyleMedalCount":10,"Suicides":0,"Team":1,"TeamScore":50,"TotalMedalCount":11,"UniqueMultiMedalCount":1,"UniqueOtherMedalCount":0,"UniqueSpreeMedalCount":0,"UniqueStyleMedalCount":3,"UniqueTotalMedalCount":4,"WeaponCarnageReport":[{"Deaths":9,"Headshots":8,"Kills":8,"Penalties":0,"WeaponId":6}]},

{"AiEventAggregates":[],"Assists":0,"AvgDeathDistanceMeters":18.5245876,"AvgKillDistanceMeters":17.28502,"Betrayals":0,"DNF":false,"Deaths":13,"DeathsOverTime":[[0,0],[28,1],[36,2],[60,3],[71,4],[95,5],[135,6],[155,7],[196,8],[218,9],[227,10],[290,11],[322,12],[356,13],[373,13]],"Headshots":12,"IndividualStandingWithNoRegardForTeams":1,"IsGuest":false,"KilledMostByCount":4,"KilledMostCount":4,"Kills":13,"KillsOverTime":[[0,0],[19,1],[91,2],[121,3],[122,4],[131,5],[197,6],[243,7],[309,8],[317,9],[322,10],[322,11],[354,12],[373,13],[373,13]],"MedalsOverTime":[[0,0],[19,1],[19,2],[91,3],[91,4],[121,5],[121,6],[122,7],[122,8],[132,9],[197,10],[197,11],[243,12],[310,13],[310,14],[317,15],[322,16],[322,17],[322,18],[354,19],[373,20],[373,21],[373,21]],"MultiMedalCount":2,"OtherMedalCount":3,"PlayerDataIndex":4,"PlayerDetail":{"CampaignProgressCoop":"CompletedLegendary","CampaignProgressSp":"CompletedLegendary","Initialized":true,"IsGuest":false,"LastGameVariantClassPlayed":"Competitive","ReachEmblem":{"background_index":39,"change_colors":[12,2,2,2],"flags":0,"foreground_index":54},"armor_completion_percentage":0.5424837,"daily_challenges_completed":485,"first_active":"\/Date(1284497580000-0700)\/","gamertag":"Severthetime","games_total":1965,"last_active":"\/Date(1298226660000-0800)\/","service_tag":"SEVR","weekly_challenges_completed":21},"PlayerKilledByMost":"TETZ21","PlayerKilledMost":"BrawniestBroom","PointsOverTime":[[0,0],[373,0]],"Rating":0,"Score":13,"SpecificMedalCounts":[{"Key":117,"Value":2},{"Key":2,"Value":2},{"Key":72,"Value":1},{"Key":93,"Value":2},{"Key":85,"Value":12},{"Key":91,"Value":2},{"Key":95,"Value":1},{"Key":101,"Value":1}],"SpreeMedalCount":0,"Standing":0,"StyleMedalCount":18,"Suicides":0,"Team":1,"TeamScore":50,"TotalMedalCount":23,"UniqueMultiMedalCount":1,"UniqueOtherMedalCount":2,"UniqueSpreeMedalCount":0,"UniqueStyleMedalCount":5,"UniqueTotalMedalCount":8,"WeaponCarnageReport":[{"Deaths":11,"Headshots":12,"Kills":12,"Penalties":0,"WeaponId":6},{"Deaths":2,"Headshots":0,"Kills":1,"Penalties":0,"WeaponId":43}]},

],"PlaylistName":"Team SWAT","Teams":[{"DeathsOverTime":[[0,0],[19,1],[28,2],[31,3],[40,4],[55,5],[74,6],[75,7],[79,8],[80,9],[91,10],[93,11],[103,12],[108,13],[113,14],[114,15],[121,16],[122,17],[131,18],[136,19],[142,20],[145,21],[152,22],[157,23],[163,24],[168,25],[170,26],[171,27],[190,28],[197,29],[214,30],[228,31],[241,32],[243,33],[243,34],[252,35],[256,36],[260,37],[263,38],[276,39],[298,40],[300,41],[300,42],[309,43],[317,44],[322,45],[322,46],[328,47],[354,48],[357,49],[373,50],[373,50]],"Exists":true,"Index":0,"KillsOverTime":[[0,0],[17,1],[22,2],[28,3],[32,4],[36,5],[50,6],[60,7],[61,8],[71,9],[93,10],[94,11],[95,12],[101,13],[115,14],[119,15],[130,16],[135,17],[139,18],[155,19],[167,20],[171,21],[176,22],[181,23],[191,24],[196,25],[202,26],[212,27],[218,28],[227,29],[232,30],[268,31],[281,32],[283,33],[290,34],[305,35],[307,36],[322,37],[340,38],[356,39],[361,40],[361,41],[367,42],[373,42]],"MedalsOverTime":[[0,0],[17,1],[17,2],[22,3],[28,4],[28,5],[32,6],[32,7],[36,8],[36,9],[50,10],[60,11],[61,12],[71,13],[93,14],[93,15],[95,16],[95,17],[101,18],[115,19],[115,20],[115,21],[119,22],[130,23],[135,24],[135,25],[139,26],[155,27],[168,28],[171,29],[176,30],[176,31],[181,32],[191,33],[191,34],[191,35],[197,36],[202,37],[213,38],[218,39],[218,40],[227,41],[227,42],[232,43],[232,44],[269,45],[281,46],[283,47],[290,48],[305,49],[307,50],[307,51],[322,52],[322,53],[340,54],[356,55],[356,56],[361,57],[361,58],[367,59],[373,59]],"MetagameScore":42,"Score":42,"Standing":1,"TeamTotalAssists":0,"TeamTotalBetrayals":0,"TeamTotalDeaths":50,"TeamTotalGameVariantCustomStat_1":0,"TeamTotalGameVariantCustomStat_2":0,"TeamTotalGameVariantCustomStat_3":0,"TeamTotalGameVariantCustomStat_4":0,"TeamTotalKills":42,"TeamTotalMedals":59,"TeamTotalSuicides":0},{"DeathsOverTime":[[0,0],[17,1],[22,2],[28,3],[32,4],[36,5],[50,6],[60,7],[61,8],[71,9],[93,10],[94,11],[95,12],[101,13],[115,14],[119,15],[130,16],[135,17],[139,18],[155,19],[167,20],[171,21],[176,22],[181,23],[191,24],[196,25],[202,26],[212,27],[218,28],[227,29],[232,30],[268,31],[281,32],[283,33],[290,34],[305,35],[307,36],[322,37],[340,38],[356,39],[361,40],[361,41],[367,42],[373,42]],"Exists":true,"Index":1,"KillsOverTime":[[0,0],[19,1],[28,2],[31,3],[40,4],[55,5],[74,6],[75,7],[79,8],[80,9],[91,10],[93,11],[103,12],[108,13],[113,14],[114,15],[121,16],[122,17],[131,18],[136,19],[142,20],[145,21],[152,22],[157,23],[163,24],[168,25],[170,26],[171,27],[190,28],[197,29],[214,30],[228,31],[241,32],[243,33],[243,34],[252,35],[256,36],[260,37],[263,38],[276,39],[298,40],[300,41],[300,42],[309,43],[317,44],[322,45],[322,46],[328,47],[354,48],[357,49],[373,50],[373,50]],"MedalsOverTime":[[0,0],[19,1],[19,2],[29,3],[31,4],[40,5],[55,6],[74,7],[75,8],[80,9],[80,10],[91,11],[91,12],[93,13],[103,14],[103,15],[108,16],[113,17],[114,18],[114,19],[121,20],[121,21],[122,22],[122,23],[132,24],[136,25],[142,26],[145,27],[145,28],[152,29],[152,30],[158,31],[163,32],[168,33],[168,34],[170,35],[170,36],[171,37],[190,38],[197,39],[197,40],[214,41],[228,42],[228,43],[241,44],[243,45],[243,46],[252,47],[256,48],[260,49],[263,50],[263,51],[277,52],[277,53],[299,54],[300,55],[300,56],[310,57],[310,58],[317,59],[322,60],[322,61],[322,62],[328,63],[354,64],[357,65],[357,66],[357,67],[373,68],[373,69],[373,69]],"MetagameScore":50,"Score":50,"Standing":0,"TeamTotalAssists":0,"TeamTotalBetrayals":0,"TeamTotalDeaths":42,"TeamTotalGameVariantCustomStat_1":0,"TeamTotalGameVariantCustomStat_2":0,"TeamTotalGameVariantCustomStat_3":0,"TeamTotalGameVariantCustomStat_4":0,"TeamTotalKills":50,"TeamTotalMedals":69,"TeamTotalSuicides":0}]}}


The only thing I could fine wrong is the that the json itself has an extra ',' (comma) that shouldn't be in there. It is the comma on the last player before "PlaylistName"

<?php

$data = '{"reason":"Okay","status":0,"GameDetails":{"BaseMapName":"Reflection","CampaignDifficulty":"Easy","CampaignGlobalScore":0,"CampaignMetagameEnabled":false,"GameDuration":373,"GameId":448434948,"GameTimestamp":"\/Date(1295993863040-0800)\/","GameVariantClass":3,"GameVariantHash":-1559817880631004487,"GameVariantIconIndex":1,"GameVariantName":"SWAT","HasDetails":true,"IsTeamGame":true,"MapName":"Reflection","MapVariantHash":-5431616218904750125,"PlayerCount":8,"Players":[{"AiEventAggregates":[],"Assists":0,"AvgDeathDistanceMeters":26.3847733,"AvgKillDistanceMeters":27.7626762,"Betrayals":0,"DNF":false,"Deaths":11,"DeathsOverTime":[[0,0],[22,1],[61,2],[93,3],[101,4],[119,5],[176,6],[191,7],[281,8],[305,9],[340,10],[367,11],[373,11]],"Headshots":14,"IndividualStandingWithNoRegardForTeams":0,"IsGuest":false,"KilledMostByCount":5,"KilledMostCount":5,"Kills":16,"KillsOverTime":[[0,0],[31,1],[55,2],[75,3],[79,4],[80,5],[93,6],[136,7],[142,8],[145,9],[152,10],[168,11],[170,12],[190,13],[214,14],[256,15],[300,16],[373,16]],"MedalsOverTime":[[0,0],[31,1],[55,2],[75,3],[80,4],[80,5],[93,6],[136,7],[142,8],[145,9],[145,10],[152,11],[152,12],[168,13],[168,14],[170,15],[170,16],[190,17],[214,18],[256,19],[300,20],[373,20]],"MultiMedalCount":3,"OtherMedalCount":0,"PlayerDataIndex":6,"PlayerDetail":{"CampaignProgressCoop":"PartialNormal","CampaignProgressSp":"None","Initialized":true,"IsGuest":false,"LastGameVariantClassPlayed":"Competitive","ReachEmblem":{"background_index":20,"change_colors":[0,0,0,2],"flags":0,"foreground_index":65},"armor_completion_percentage":0.307189554,"daily_challenges_completed":111,"first_active":"\/Date(1284443880000-0700)\/","gamertag":"Venomous Karnij","games_total":544,"last_active":"\/Date(1298086260000-0800)\/","service_tag":"JMAN","weekly_challenges_completed":2},"PlayerKilledByMost":"Yrmt1964","PlayerKilledMost":"Yrmt1964","PointsOverTime":[[0,0],[373,0]],"Rating":0,"Score":16,"SpecificMedalCounts":[{"Key":117,"Value":1},{"Key":11,"Value":1},{"Key":2,"Value":3},{"Key":85,"Value":14},{"Key":95,"Value":1},{"Key":104,"Value":1}],"SpreeMedalCount":1,"Standing":0,"StyleMedalCount":17,"Suicides":0,"Team":1,"TeamScore":50,"TotalMedalCount":21,"UniqueMultiMedalCount":1,"UniqueOtherMedalCount":0,"UniqueSpreeMedalCount":1,"UniqueStyleMedalCount":4,"UniqueTotalMedalCount":6,"WeaponCarnageReport":[{"Deaths":11,"Headshots":14,"Kills":15,"Penalties":0,"WeaponId":6},{"Deaths":0,"Headshots":0,"Kills":1,"Penalties":0,"WeaponId":43}]},{"AiEventAggregates":[],"Assists":0,"AvgDeathDistanceMeters":31.5024147,"AvgKillDistanceMeters":24.3540745,"Betrayals":0,"DNF":false,"Deaths":9,"DeathsOverTime":[[0,0],[17,1],[32,2],[94,3],[130,4],[167,5],[181,6],[202,7],[283,8],[361,9],[373,9]],"Headshots":8,"IndividualStandingWithNoRegardForTeams":3,"IsGuest":false,"KilledMostByCount":4,"KilledMostCount":3,"Kills":8,"KillsOverTime":[[0,0],[28,1],[103,2],[163,3],[243,4],[260,5],[263,6],[300,7],[328,8],[373,8]],"MedalsOverTime":[[0,0],[29,1],[103,2],[103,3],[163,4],[243,5],[260,6],[263,7],[263,8],[300,9],[328,10],[373,10]],"MultiMedalCount":1,"OtherMedalCount":0,"PlayerDataIndex":7,"PlayerDetail":{"CampaignProgressCoop":"PartialNormal","CampaignProgressSp":"CompletedLegendary","Initialized":true,"IsGuest":false,"LastGameVariantClassPlayed":"Competitive","ReachEmblem":{"background_index":35,"change_colors":[9,2,26,17],"flags":1,"foreground_index":0},"armor_completion_percentage":0.457516342,"daily_challenges_completed":89,"first_active":"\/Date(1284438000000-0700)\/","gamertag":"Jam1efoster","games_total":624,"last_active":"\/Date(1295993880000-0800)\/","service_tag":"J","weekly_challenges_completed":4},"PlayerKilledByMost":"TETZ21","PlayerKilledMost":"Yrmt1964","PointsOverTime":[[0,0],[373,0]],"Rating":0,"Score":8,"SpecificMedalCounts":[{"Key":117,"Value":1},{"Key":2,"Value":1},{"Key":85,"Value":8},{"Key":101,"Value":1}],"SpreeMedalCount":0,"Standing":0,"StyleMedalCount":10,"Suicides":0,"Team":1,"TeamScore":50,"TotalMedalCount":11,"UniqueMultiMedalCount":1,"UniqueOtherMedalCount":0,"UniqueSpreeMedalCount":0,"UniqueStyleMedalCount":3,"UniqueTotalMedalCount":4,"WeaponCarnageReport":[{"Deaths":9,"Headshots":8,"Kills":8,"Penalties":0,"WeaponId":6}]},{"AiEventAggregates":[],"Assists":0,"AvgDeathDistanceMeters":18.5245876,"AvgKillDistanceMeters":17.28502,"Betrayals":0,"DNF":false,"Deaths":13,"DeathsOverTime":[[0,0],[28,1],[36,2],[60,3],[71,4],[95,5],[135,6],[155,7],[196,8],[218,9],[227,10],[290,11],[322,12],[356,13],[373,13]],"Headshots":12,"IndividualStandingWithNoRegardForTeams":1,"IsGuest":false,"KilledMostByCount":4,"KilledMostCount":4,"Kills":13,"KillsOverTime":[[0,0],[19,1],[91,2],[121,3],[122,4],[131,5],[197,6],[243,7],[309,8],[317,9],[322,10],[322,11],[354,12],[373,13],[373,13]],"MedalsOverTime":[[0,0],[19,1],[19,2],[91,3],[91,4],[121,5],[121,6],[122,7],[122,8],[132,9],[197,10],[197,11],[243,12],[310,13],[310,14],[317,15],[322,16],[322,17],[322,18],[354,19],[373,20],[373,21],[373,21]],"MultiMedalCount":2,"OtherMedalCount":3,"PlayerDataIndex":4,"PlayerDetail":{"CampaignProgressCoop":"CompletedLegendary","CampaignProgressSp":"CompletedLegendary","Initialized":true,"IsGuest":false,"LastGameVariantClassPlayed":"Competitive","ReachEmblem":{"background_index":39,"change_colors":[12,2,2,2],"flags":0,"foreground_index":54},"armor_completion_percentage":0.5424837,"daily_challenges_completed":485,"first_active":"\/Date(1284497580000-0700)\/","gamertag":"Severthetime","games_total":1965,"last_active":"\/Date(1298226660000-0800)\/","service_tag":"SEVR","weekly_challenges_completed":21},"PlayerKilledByMost":"TETZ21","PlayerKilledMost":"BrawniestBroom","PointsOverTime":[[0,0],[373,0]],"Rating":0,"Score":13,"SpecificMedalCounts":[{"Key":117,"Value":2},{"Key":2,"Value":2},{"Key":72,"Value":1},{"Key":93,"Value":2},{"Key":85,"Value":12},{"Key":91,"Value":2},{"Key":95,"Value":1},{"Key":101,"Value":1}],"SpreeMedalCount":0,"Standing":0,"StyleMedalCount":18,"Suicides":0,"Team":1,"TeamScore":50,"TotalMedalCount":23,"UniqueMultiMedalCount":1,"UniqueOtherMedalCount":2,"UniqueSpreeMedalCount":0,"UniqueStyleMedalCount":5,"UniqueTotalMedalCount":8,"WeaponCarnageReport":[{"Deaths":11,"Headshots":12,"Kills":12,"Penalties":0,"WeaponId":6},{"Deaths":2,"Headshots":0,"Kills":1,"Penalties":0,"WeaponId":43}]} ],"PlaylistName":"Team SWAT","Teams":[{"DeathsOverTime":[[0,0],[19,1],[28,2],[31,3],[40,4],[55,5],[74,6],[75,7],[79,8],[80,9],[91,10],[93,11],[103,12],[108,13],[113,14],[114,15],[121,16],[122,17],[131,18],[136,19],[142,20],[145,21],[152,22],[157,23],[163,24],[168,25],[170,26],[171,27],[190,28],[197,29],[214,30],[228,31],[241,32],[243,33],[243,34],[252,35],[256,36],[260,37],[263,38],[276,39],[298,40],[300,41],[300,42],[309,43],[317,44],[322,45],[322,46],[328,47],[354,48],[357,49],[373,50],[373,50]],"Exists":true,"Index":0,"KillsOverTime":[[0,0],[17,1],[22,2],[28,3],[32,4],[36,5],[50,6],[60,7],[61,8],[71,9],[93,10],[94,11],[95,12],[101,13],[115,14],[119,15],[130,16],[135,17],[139,18],[155,19],[167,20],[171,21],[176,22],[181,23],[191,24],[196,25],[202,26],[212,27],[218,28],[227,29],[232,30],[268,31],[281,32],[283,33],[290,34],[305,35],[307,36],[322,37],[340,38],[356,39],[361,40],[361,41],[367,42],[373,42]],"MedalsOverTime":[[0,0],[17,1],[17,2],[22,3],[28,4],[28,5],[32,6],[32,7],[36,8],[36,9],[50,10],[60,11],[61,12],[71,13],[93,14],[93,15],[95,16],[95,17],[101,18],[115,19],[115,20],[115,21],[119,22],[130,23],[135,24],[135,25],[139,26],[155,27],[168,28],[171,29],[176,30],[176,31],[181,32],[191,33],[191,34],[191,35],[197,36],[202,37],[213,38],[218,39],[218,40],[227,41],[227,42],[232,43],[232,44],[269,45],[281,46],[283,47],[290,48],[305,49],[307,50],[307,51],[322,52],[322,53],[340,54],[356,55],[356,56],[361,57],[361,58],[367,59],[373,59]],"MetagameScore":42,"Score":42,"Standing":1,"TeamTotalAssists":0,"TeamTotalBetrayals":0,"TeamTotalDeaths":50,"TeamTotalGameVariantCustomStat_1":0,"TeamTotalGameVariantCustomStat_2":0,"TeamTotalGameVariantCustomStat_3":0,"TeamTotalGameVariantCustomStat_4":0,"TeamTotalKills":42,"TeamTotalMedals":59,"TeamTotalSuicides":0},{"DeathsOverTime":[[0,0],[17,1],[22,2],[28,3],[32,4],[36,5],[50,6],[60,7],[61,8],[71,9],[93,10],[94,11],[95,12],[101,13],[115,14],[119,15],[130,16],[135,17],[139,18],[155,19],[167,20],[171,21],[176,22],[181,23],[191,24],[196,25],[202,26],[212,27],[218,28],[227,29],[232,30],[268,31],[281,32],[283,33],[290,34],[305,35],[307,36],[322,37],[340,38],[356,39],[361,40],[361,41],[367,42],[373,42]],"Exists":true,"Index":1,"KillsOverTime":[[0,0],[19,1],[28,2],[31,3],[40,4],[55,5],[74,6],[75,7],[79,8],[80,9],[91,10],[93,11],[103,12],[108,13],[113,14],[114,15],[121,16],[122,17],[131,18],[136,19],[142,20],[145,21],[152,22],[157,23],[163,24],[168,25],[170,26],[171,27],[190,28],[197,29],[214,30],[228,31],[241,32],[243,33],[243,34],[252,35],[256,36],[260,37],[263,38],[276,39],[298,40],[300,41],[300,42],[309,43],[317,44],[322,45],[322,46],[328,47],[354,48],[357,49],[373,50],[373,50]],"MedalsOverTime":[[0,0],[19,1],[19,2],[29,3],[31,4],[40,5],[55,6],[74,7],[75,8],[80,9],[80,10],[91,11],[91,12],[93,13],[103,14],[103,15],[108,16],[113,17],[114,18],[114,19],[121,20],[121,21],[122,22],[122,23],[132,24],[136,25],[142,26],[145,27],[145,28],[152,29],[152,30],[158,31],[163,32],[168,33],[168,34],[170,35],[170,36],[171,37],[190,38],[197,39],[197,40],[214,41],[228,42],[228,43],[241,44],[243,45],[243,46],[252,47],[256,48],[260,49],[263,50],[263,51],[277,52],[277,53],[299,54],[300,55],[300,56],[310,57],[310,58],[317,59],[322,60],[322,61],[322,62],[328,63],[354,64],[357,65],[357,66],[357,67],[373,68],[373,69],[373,69]],"MetagameScore":50,"Score":50,"Standing":0,"TeamTotalAssists":0,"TeamTotalBetrayals":0,"TeamTotalDeaths":42,"TeamTotalGameVariantCustomStat_1":0,"TeamTotalGameVariantCustomStat_2":0,"TeamTotalGameVariantCustomStat_3":0,"TeamTotalGameVariantCustomStat_4":0,"TeamTotalKills":50,"TeamTotalMedals":69,"TeamTotalSuicides":0}]}}';

$obj = json_decode($data);
foreach($obj->GameDetails->Players as $players) {
    if ($players->PlayerDetail->gamertag == 'Jam1efoster') {
        foreach($players->SpecificMedalCounts as $SpecificMedalCounts) {
            $medal = $SpecificMedalCounts;
            echo '<pre>'.print_r($medal,1).'</pre>';
        }
    }
}

OUTPUT

<pre>stdClass Object
(
    [Key] => 117
    [Value] => 1
)
</pre><pre>stdClass Object
(
    [Key] => 2
    [Value] => 1
)
</pre><pre>stdClass Object
(
    [Key] => 85
    [Value] => 8
)
</pre><pre>stdClass Object
(
    [Key] => 101
    [Value] => 1
)
</pre>


Looks like something like this should work fine:

foreach($obj["GameDetails"]["Players"] as $players) {
    if ($players["PlayerDetail"]["gamertag"] == "Jam1efoster") {
        // do something
    }
}


foreach($obj->GameDetails->Players as $players) {
    if ($players->PlayerDetail->gamertag == $gamertag) {
        foreach($players->SpecificMedalCounts as $SpecificMedalCounts) {
            $medal = $SpecificMedalCounts;
            echo '<pre>'.print_r($medal,1).'</pre>';
        }
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜