如何将数组json转换为字符串?

时间:2017-01-28 13:39:28

标签: php mysql arrays json api

如何将数组更改为一个字符串uning php?

这是数组

{
    "result": "success", 
    "message": [ 
        { 
            "date_insert": "2017-01-28 20:14:51", 
            "date_update": "2017-01-28 20:15:11", 
            "weather": "sunny"
        }
    ]
}

我希望天气输出为字符串。感谢

1 个答案:

答案 0 :(得分:2)

首先使用带有第二个参数json_decode()的{​​{1}}将json转换为数组。然后访问每个数组元素。

true

有关详情,请参阅文档http://php.net/manual/en/function.json-decode.php