【发布时间】:2014-07-01 17:05:39
【问题描述】:
$id = '76561198036414106';
$key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$link2 = file_get_contents('http://api.steampowered.com/ISteamUser/GetFriendList/v0001/?key=' . $key . '&steamid=' . $id . '&relationship=friend');
$myarray2 = json_decode($link2, true);
foreach ($myarray2['friendslist']['friends'] as $type) {
echo "<br>id: " . $type['steamid'];
[save this $type['steamid'] into a var, then do a foreach again and save down the next to another variable]
}
如何将 foreach 输出的输出保存到多个变量? var1、var2、var3 等,直到数组不再输出任何内容。
我想要做的是这个脚本会在 Steam 上获取我所有朋友的社区 ID,然后我将获取这些 ID 并通过另一个 api 调用运行它们,这将获取我的朋友们玩某个游戏的次数在过去 2 周内。所以我需要的只是如何保存 api 输出的所有社区 ID,并将它们全部放在一个单独的变量中。
【问题讨论】: