首页 > 代码库 > php json_decode 和json_encode
php json_decode 和json_encode
json_decode
(PHP 5 >= 5.2.0, PECL json >= 1.2.0)
json_decode — 对 JSON 格式的字符串进行编码
说明
mixed json_decode ( string $json [, bool $assoc ] )
接受一个 JSON 格式的字符串并且把它转换为 PHP 变量
参数
json
待解码的 json string 格式的字符串。
assoc
当该参数为 TRUE 时,将返回 array 而非 object 。
即:当assoc 为true 的时候
$json = ‘{"a":1,"b":2,"c":3,"d":4,"e":5}‘;
$a = json_decode ( string $json , true) ;
echo $a[‘aa‘];//可以使用a[‘aa‘] 这种形式获取对应的值
php json_decode 和json_encode
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。