how can i get all "steamids" from Players where "gameid" exist and have the value "730"?
it Shows:
NOTICE Undefined property: stdClass::$gameid on line number 31
because "gameid" doesnt exist in every element
Code:
$players = json_decode(file_get_contents("test.json"));
foreach($players->response->Players as $mydata)
{
if($players->gameid == "730"){
echo $mydata->steamid . "\n";
}
}
My json:
{
"response": {
"players": [
{
"steamid": "76561198273176399",
"loccountrycode": "US"
},
{
"steamid": "76561198386141115",
"gameid": "730",
"loccountrycode": "DE"
},
{
"steamid": "76561198019025166",
"gameid": "730",
"loccountrycode": "RU"
},
{
"steamid": "76561198010529217",
"loccountrycode": "DK"
}
]
}
}
Thanks a lot. With best regards.