我有一個stdClass
物體看起來像這樣,我想echo
出steamid
如何在stdClass對象中訪問此字符串?
stdClass Object
(
[response] => stdClass Object
(
[players] => Array
(
[0] => stdClass Object
(
[steamid] => 76561198039509812
[communityvisibilitystate] => 1
[profilestate] => 1
[personaname] => Mike_Ock_Hurtz
[lastlogoff] => 1506899637
[profileurl] => http://steamcommunity.com/profiles/76561198039509812/
[avatar] => https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/fe/fef49e7fa7e1997310d705b2a6158ff8dc1cdfeb.jpg
[avatarmedium] => https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/fe/fef49e7fa7e1997310d705b2a6158ff8dc1cdfeb_medium.jpg
[avatarfull] => https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/fe/fef49e7fa7e1997310d705b2a6158ff8dc1cdfeb_full.jpg
[personastate] => 0
)
)
)
)
下面是我如何得到上面:
foreach(updateBanList::readFile($file) as $steamprofiles){
$steam = $steamUser->GetPlayerSummariesV2($steamprofiles[0]);
print_r($steam);
$players = $steam->response->players;
}
迄今訪問類的我已使用
$players = $steam->response->players;
這讓我到最後array
Array
(
[0] => stdClass Object
(
[steamid] => 76561198039509812
[communityvisibilitystate] => 1
[profilestate] => 1
[personaname] => Mike_Ock_Hurtz
[lastlogoff] => 1506899637
[profileurl] => http://steamcommunity.com/profiles/76561198039509812/
[avatar] => https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/fe/fef49e7fa7e1997310d705b2a6158ff8dc1cdfeb.jpg
[avatarmedium] => https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/fe/fef49e7fa7e1997310d705b2a6158ff8dc1cdfeb_medium.jpg
[avatarfull] => https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/fe/fef49e7fa7e1997310d705b2a6158ff8dc1cdfeb_full.jpg
[personastate] => 0
)
)
我想echo
出steamid
,我嘗試了幾件事情,我知道不管它是我做的是非常簡單的,但其在尾盤,我無法弄清楚。
如果我嘗試
$players->steamid;
我得到的錯誤
注意:試圖如果我嘗試
$players['steamid'];
獲得非對象
財產我明白了
注意:未定義指數:steamid
我在做什麼錯?