标签: php json
我正在尝试从单独的JSON文件中转储数组。当我转储数组时,它返回“ NULL”。
下面的代码用于将JSON数组转换为PHP数组,然后将其转储到页面中。
$rightcont = file_get_contents("./pass.json"); var_dump(json_decode($rightcont));
$rightcont = file_get_contents("./pass.json");
var_dump(json_decode($rightcont));
pass.json文件包括:
{"user": ["username":"foo","password":"bar"}
我在做什么错了?
答案 0 :(得分:1)
两件事(工作示例here):
{"user": {"username":"foo","password":"bar" }}
json_decode($rightcont, true)