PHP json_decode()函数以及参数用法

json_decode(value,option)
参数描述
value必填。待解码的json字符串 。该函数只能接受 UTF-8 编码的数据
options可选 默认 false 转为对象。
true 转为数组。
<?php
$json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';
var_dump(json_decode($json));
var_dump(json_decode($json, true));
?>

以上例程会输出:

object(stdClass)#1 (5) {    
["a"] => int(1)    
["b"] => int(2)    
["c"] => int(3)    
["d"] => int(4)    
["e"] => int(5)} 

array(5) {    
["a"] => int(1)    
["b"] => int(2)    
["c"] => int(3)    
["d"] => int(4)    
["e"] => int(5)}


内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://sulao.cn/post/207.html

我要评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。