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)}