更改 PHP 或 CakePHP 中给定数组的结构?
我有下面的数组。
Array
(
[Image] => Array
(
[0] => Array
(
[thumbnail_url] => http://www.xyz.com/img/uploadsChatImage/42/thumbnails/chicken_1.png
)
[1] => Array
(
[name] => chicken_1.png
)
[2] => Array
(
[thumbnail_url] => http://www.xyz.com/img/uploadsChatImage/42/thumbnails/chicken_2.png
)
[3] => Array
(
[name] => chicken_2.png
)
[4] => Array
(
[thumbnail_url] => http://www.xyz.com/img/uploadsChatImage/42/thumbnails/chicken_3.png
)
[5] => Array
(
[name] => chicken_3.png
)
)
)
但我想要这样的东西
Array
(
[Image] => Array
(
[0] => Array
(
[thumbnail_url] => http://www.xyz.com/img/uploadsChatImage/42/thumbnails/chicken_1.png
[name] => chicken_1.png
)
[1] => Array
(
[thumbnail_url] => http://www.xyz.com/img/uploadsChatImage/42/thumbnails/chicken_2.png
[name] => chicken_2.png
)
[2] => Array
(
[thumbnail_url] => http://www.xyz.com/img/uploadsChatImage/42/thumbnails/chicken_3.png
[name] => chicken_3.png
)
)
)
我该怎么办?
提前致谢
I have below array.
Array
(
[Image] => Array
(
[0] => Array
(
[thumbnail_url] => http://www.xyz.com/img/uploadsChatImage/42/thumbnails/chicken_1.png
)
[1] => Array
(
[name] => chicken_1.png
)
[2] => Array
(
[thumbnail_url] => http://www.xyz.com/img/uploadsChatImage/42/thumbnails/chicken_2.png
)
[3] => Array
(
[name] => chicken_2.png
)
[4] => Array
(
[thumbnail_url] => http://www.xyz.com/img/uploadsChatImage/42/thumbnails/chicken_3.png
)
[5] => Array
(
[name] => chicken_3.png
)
)
)
But I want to something like this
Array
(
[Image] => Array
(
[0] => Array
(
[thumbnail_url] => http://www.xyz.com/img/uploadsChatImage/42/thumbnails/chicken_1.png
[name] => chicken_1.png
)
[1] => Array
(
[thumbnail_url] => http://www.xyz.com/img/uploadsChatImage/42/thumbnails/chicken_2.png
[name] => chicken_2.png
)
[2] => Array
(
[thumbnail_url] => http://www.xyz.com/img/uploadsChatImage/42/thumbnails/chicken_3.png
[name] => chicken_3.png
)
)
)
What should I do for this?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
像这样,例如
或
结果是
Like this, for example
or
Result is
你也可以这样做:
You could also do it like this: