知识问答
php如何将json字符串转为数组
2026-11-22 18:47:01
来源:互联网转载
函数介绍:
(推荐教程:php视频教程)
json_decode接受一个JSON格式的字符串并且把它转换为PHP变量 ,当该参数$assoc为TRUE时,将返回array,否则返回object。
语法格式:
立即学习“PHP免费学习笔记(深入)”;
json_decode(string $json[,bool $assoc = false[,int $depth = 512[,int $options = 0]]])
代码实现:
<?php $json = '{"a":"php","b":"mysql","c":3}'; $json_Class=json_decode($json); $json_Array=json_decode($json, true); print_r($json_Class); print_r($json_Array); ?>输出结果:
stdClass Object ( [a] => php [b] => mysql [c] => 3 ) Array ( [a] => php [b] => mysql [c] => 3 )
相关推荐:php培训
下一篇:excel中填充柄在哪里