4,250
社区成员
发帖
与我相关
我的任务
分享$filename = "json.txt";
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);
var_dump($contents);
var_dump(json_decode($contents);
mixed json_decode ( string $json [, bool $assoc ] )
{
"programmers": [{
"firstName": "Brett",
"lastName": "McLaughlin",
"email": "brett@newInstance.com"
} ],
"authors": [{
"firstName": "Isaac",
"lastName": "Asimov",
"genre": "science fiction"
} ],
"musicians": [{
"firstName": "Eric",
"lastName": "Clapton",
"instrument": "guitar"
} ]
}$json = json_decode(file_get_contents("json.txt"));
echo "<pre>".var_export($json,true)."</pre>";