我试图从数组json获取电子邮件,但它返回空值

[
    {
        "name": "Arun",
        "email": "[email protected]"
    },
    {
        "name": "Arun kumar",
        "email": "[email protected]"
    }
]

我的json查询是select json->>"$.name" as email from json
但此查询返回空值

最佳答案

我测试了以下内容,并为我编写了json示例

$json='[{"name": "Arun", "email": "[email protected]"}, {"name": "Arun kumar", "email": "[email protected]"}]';
$data=json_decode($json,true);

foreach ($data as $key => $value) {
    echo $value["email"] . "<br>";
}

09-12 17:20