我无法输出:
[{"title":"London","foo":"bar"},{"title":"Istanbul","foo":"bar"}]
Run Code Online (Sandbox Code Playgroud)
我不能在这里逗号: },{
我可以输出这个[{"title":"London","foo":"bar"}]但不是第一个例子.
这将产生所需的输出:
$data = array(
array("title" => "London",
"foo" => "bar"
),
array("title" => "Istanbul",
"foo" => "bar"
)
);
echo json_encode($data);
Run Code Online (Sandbox Code Playgroud)
确保正确创建阵列.有关更多信息,请查看文档json_decode.