json转数组 php
在进行 web 开发的过程中,我们经常需要将 JSON 数据格式转换为数组。PHP 语言具有很好的处理 JSON 的能力,可以快速地将 JSON 格式的数据转换为数组。
在 PHP 中,有内置的 json_decode() 函数和 json_encode() 函数可以实现 JSON 与数组之间的转换。下面我们将分别介绍这两个函数的使用方法。
一、json_decode() 函数
json_decode() 函数用于将 JSON 数据格式转换为 PHP 数组。它的语法如下:
mixed json_decode ( string $json [, bool $assoc = FALSE [, int $depth = 512 [, int $options = 0 ]]] )
发表评论