如何使用 PHP 解析 JSON 文件?
我试图使用PHP解析JSON文件。但我现在被困住了。
这是我的 JSON 文件的内容:
{
    "John": {
        "status":"Wait"
    },
    "Jennifer": {
        "status":"Active"
    },
    "James": {
        "status":"Active",
        "age":56,
        "count":10,
        "progress":0.0029857,
        "bad":0
    }
}
这就是我到目前为止所尝试的:
<?php
$string = file_get_contents("/home/michael/test.json");
$json_a = json_decode($string, true);
echo $json_a['John'][status];
echo $json_a['Jennifer'][status];
但是因为我事先不知道名称(如,)以及所有可用的键和值(如,),我认为我需要创建一些foreach循环。'John''Jennifer''age''count'
我希望能有这样一个例子。
 
					 
				 
				    		 
				    		 
				    		