【发布时间】:2013-10-29 08:26:30
【问题描述】:
鉴于这个 stdClass 结构...
[RecentAchievements] => stdClass Object
(
[1446] => stdClass Object
(
[3319] => stdClass Object
(
[ID] => 3319
[GameID] => 1446
[Title] => Hello World!
[Description] => Complete World 1-1
[Points] => 15
[BadgeName] => 03909
[IsAwarded] => 1
[DateAwarded] => 2013-10-20 19:35:46
)
我需要检查 3319 里面的对象,比如“标题”,所以它是这样的:
$data->RecentAchievements->$gameid->ACHVIDHERE->Title;
要获取$gameid,它来自其他对象(RecentlyPlayed),这样:
[RecentlyPlayed] => Array
(
[0] => stdClass Object
(
[GameID] => 1446
[ConsoleID] => 7
[ConsoleName] => NES
[Title] => Super Mario Bros
[LastPlayed] => 2013-10-20 21:38:22
[ImageIcon] => /Images/000385.png
[ImageTitle] => /Images/000272.png
[ImageIngame] => /Images/000387.png
[ImageBoxArt] => /Images/000275.png
)
)
$gameid = $data3->RecentlyPlayed['0']->GameID;
API 不允许我使用相同的最近播放来获取成就 ID,我必须从最近的成就中提取它。有可能吗?
【问题讨论】:
-
对我来说似乎不太可能在需要访问该元素时获得该 ID。您不能通过现有电话获取更多信息以获取
$gameid吗?例如要求它返回一个包含两个值的数组? -
您的意思是将对象转换为数组并提取ID?也许是的,但我正在寻找更干净的东西(如果可能的话)。