Приветствую всех.
Есть код
$getUrl = file_get_contents("http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/?key=B376BB79D322BCB7B00B88B1C2DA637E&steamid=76561198027888875&format=json");
$rez = json_decode($getUrl);
$rez = $rez->response->games;
echo "<pre>";
print_r($rez);
echo "</pre>";
Этот код выводит ответ в виде :
Array
(
[0] => stdClass Object
(
[appid] => 10
[playtime_2weeks] => 1
[playtime_forever] => 182860
)
[1] => stdClass Object
(
[appid] => 30
[playtime_forever] => 0
)
[2] => stdClass Object
(
[appid] => 40
[playtime_forever] => 0
)
[3] => stdClass Object
(
[appid] => 60
[playtime_forever] => 0
)
[4] => stdClass Object
(
[appid] => 80
[playtime_forever] => 163
)
[5] => stdClass Object
(
[appid] => 100
[playtime_forever] => 0
)
[6] => stdClass Object
(
[appid] => 240
[playtime_forever] => 19009
)
[7] => stdClass Object
(
[appid] => 300
[playtime_forever] => 0
)
[8] => stdClass Object
(
[appid] => 320
[playtime_forever] => 0
)
[9] => stdClass Object
(
[appid] => 340
[playtime_forever] => 0
)
[10] => stdClass Object
(
[appid] => 205790
[playtime_forever] => 0
)
[11] => stdClass Object
(
[appid] => 730
[playtime_forever] => 1005
)
[12] => stdClass Object
(
[appid] => 48700
[playtime_forever] => 0
)
)
Как получить appid ?
Такое
foreach ($rez->response->games as $val) {
echo $val['appid'];
}
и такое
foreach ($rez->response->games as $val) {
echo $val->appid;
}
Не работает. Помогите пожалуйста.