我在访问 JSON 中的元素时遇到了一些问题。这是我的代码:
$raw_json = '{
"players": [
{
"steamid": "76561197960435530",
"communityvisibilitystate": 3,
"profilestate": 1,
"personaname": "Robin",
"lastlogoff": 1365134746,
"profileurl": "http://steamcommunity.com/id/robinwalker/",
"avatar": "http://media.steampowered.com/steamcommunity/public/images/avatars/f1/f1dd60a188883caf82d0cbfccfe6aba0af1732d4.jpg",
"avatarmedium": "http://media.steampowered.com/steamcommunity/public/images/avatars/f1/f1dd60a188883caf82d0cbfccfe6aba0af1732d4_medium.jpg",
"avatarfull": "http://media.steampowered.com/steamcommunity/public/images/avatars/f1/f1dd60a188883caf82d0cbfccfe6aba0af1732d4_full.jpg",
"personastate": 0,
"realname": "Robin Walker",
"primaryclanid": "103582791429521412",
"timecreated": 1063407589,
"loccountrycode": "US",
"locstatecode": "WA",
"loccityid": 3961
}
}
}';
$data = json_decode($raw_json);
print $data->players{'realname'};
我的问题是 - 我怎样才能访问像 personname 或 realname 这样的数组?