2012-05-17 102 views
-2

我创建一个JSON输出,这是它的外观现在:创建JSON输出

{"attributes":{"next":4189646},"images":{"0":{"id":"4188043","title":"Easter Island .... 

,但我希望它看起来像:

{"attributes":{"next":4197237},"images":[{"id":4198434,"title":"Good Morning" ... 

我怎么能摆脱images数组ID

+0

你最初的一组数据是什么?你想要什么对象json_encode?很可能,您需要将图像数组更改为相应的对象。 –

回答

3

为了将数组编码为[...]而不是{"0":...},该数组必须是“纯”索引数组。

这可以通过首先运行array_values()来轻松实现。

+0

谢谢,那正是我想要的,等待9分钟来接受你的回答;) –