json_decode

(no version information, might be only in CVS)

json_decode -- 瀵?JSON ?煎????绗?覆杩??缂??

说明

mixed json_decode ( string json [, bool assoc] )

?ュ??涓?JSON ?煎????绗?覆骞朵????杞??涓?PHP ???

参数

json

寰?В??? json string ?煎????绗?覆??

assoc

褰?????涓?TRUE ?讹?灏????array ??? object ??

返回值

Returns an object or if the optional assoc parameter is TRUE, an associative array is instead returned.

范例

例 1. json_decode() ???瀛?/title> [1]

备注

[1]
<?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)
}