【发布时间】:2015-05-12 13:18:05
【问题描述】:
我是一个新手程序员,我现在有点迷失方向。我想从“gameId”中获取数据并将其保存到变量中。
打印 $recentgames:
print_r($recentgames);
返回给我这个:
stdClass Object (
[summonerId] => 40300606,
[games] => Array (
[0] => stdClass Object (
[gameId] => 2102575613 ...
我想将“2102575613”存储到$gamesid。但是我的代码不起作用。
$gamesid = $recentgames->array[0]->gameId;
//I have also tried this code
$gamesid = $recentgames->object->games->array[0]->gameId;
//and this one
$gamesid = $recentgames->$object->$games->$array[0]->gameId;
任何帮助将不胜感激。
【问题讨论】:
-
$gamesid=$recentgames->games[0]->gameId; -
成功了,非常感谢
标签: php arrays object stdclass