希望以以下格式输出 json:
[{"Montgomery":[{"red":"12:34:56","yellow":"11:44:46","orange":"10:54:36","green":"9:24:26","purple":"8:14:16"}],"Suburban":[{"red":"12:34:56","yellow":"11:44:46","orange":"10:54:36","green":"9:24:26","purple":"8:14:16"}],"Shady Grove Adventist":[{"red":"12:34:56","yellow":"11:44:46","orange":"10:54:36","green":"9:24:26","purple":"8:14:16"}],"Holy Cross":[{"red":"12:34:56","yellow":"11:44:46","orange":"10:54:36","green":"9:24:26","purple":"8:14:16"}],"Washington Adventist":[{"red":"12:34:56","yellow":"11:44:46","orange":"10:54:36","green":"9:24:26","purple":"8:14:16"}]}]
我的代码:
$xyz[] = array("Montgomery"=> array("Red" => "12:00", "Yellow" => "14:00"));
$xyz[] = array("Suburban"=> array("Yellow" => "16:00"));
echo '[' . json_encode($xyz) . ']';
我的结果:
[[{"Montgomery":{"Red":"12:00","Yellow":"14:00"}},{"Suburban":{"Yellow":"16:00"}}]]