我一直在寻找遍布interwebz的一个简单的答案,但找不到任何。所以,问题是:PHP Json查看是否存在值
我打算解码一些JSON来查看是否存在一个值;尽管如此,我认为我没有做对。我想检查appid:730的值是否存在。
这里的JSON:
{
response: {
game_count: 106,
games: [
{
appid: 10,
playtime_forever: 67
},
{
appid: 730,
playtime_forever: 0
},
{
appid: 368900,
playtime_forever: 0
},
{
appid: 370190,
playtime_forever: 0
},
]
}
}
这就是我想要的:
$json = file_get_contents('JSON URL HERE');
$msgArray = json_decode($json, true);
if (appid: 730 exists) {
...
}
谢谢,希望我解释不够。
1.在foreach中使用'$ msgArray',然后在tree下查找'games'数组。 –
'json'没有回应... [无效的Json](https://3v4l.org/ld9Oa) –