开发者

How to output this json {},{} with php?

I was unable to output this:

[{"title":"London","foo":"bar"},{"title":"Istanbul"开发者_如何转开发,"foo":"bar"}]

I cannot make comma here: },{

I can output this [{"title":"London","foo":"bar"}] but not the first example.


This will produce the desired output:

$data = array(
    array("title" => "London",
          "foo" => "bar"
    ), 
    array("title" => "Istanbul",
          "foo" => "bar"
    )
);

echo json_encode($data);

Make sure you create your arrays correctly. For more information have a look at the documentation for json_decode.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜