查找php中的JSONArray中是否存在值

时间:2012-11-16 07:24:35

标签: php json

我有一个JSONArray,如下所示

{
    "output": [
        "a",
        "b",
        "c",
        "d",
        "e"
    ]
}

我需要找到php中的上述数组中是否存在“e”。有人可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:12)

$array = json_decode($json, true);
if (in_array('e', $array['output'])) {
    ...
}