合并多维数组的数据
我有这种数组
Array ( [0] => Array ( [id] => 1
[name] => PeopleOne
[address] => AddressOneOfPeopleOne
[1] => Array ( [id] => 2
[name] => PeopleTwo
[address] => AddressOneOfPeopleTwo
[2] => Array ( [id] => 3
[name] => PeopleThree
[address] => AddressOneOfPeopleThree
[3] => Array ( [id] => 4
[name] => PeopleOne
[address] => AddressTwoOfPeopleOne
,我想要这种格式,
Array ( [0] => Array ( [id] => 1
[name] => PeopleOne
[address] => Array(
[0] => AddressOneOfPeopleOne
[1] => AddressTwoOfPeopleOne
)
[1] => Array ( [id] => 2
[name] => PeopleTwo
[address] => AddressOneOfPeopleTwo
[2] => Array ( [id] => 3
[name] => PeopleThree
[address] => AddressOneOfPeopleThree
我不知道该怎么办? 有人可以解决这个问题吗?
I have this kind of array
Array ( [0] => Array ( [id] => 1
[name] => PeopleOne
[address] => AddressOneOfPeopleOne
[1] => Array ( [id] => 2
[name] => PeopleTwo
[address] => AddressOneOfPeopleTwo
[2] => Array ( [id] => 3
[name] => PeopleThree
[address] => AddressOneOfPeopleThree
[3] => Array ( [id] => 4
[name] => PeopleOne
[address] => AddressTwoOfPeopleOne
and I want this kind of format
Array ( [0] => Array ( [id] => 1
[name] => PeopleOne
[address] => Array(
[0] => AddressOneOfPeopleOne
[1] => AddressTwoOfPeopleOne
)
[1] => Array ( [id] => 2
[name] => PeopleTwo
[address] => AddressOneOfPeopleTwo
[2] => Array ( [id] => 3
[name] => PeopleThree
[address] => AddressOneOfPeopleThree
I don't know how to do?
Could anyone please solve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我有一种感觉,这并不完全是您正在寻找的,但我不完全确定最终数组中需要什么。至少在一开始,情况如何?
I have a feeling this isn't exactly what you're looking for, but I'm not entirely sure what needs to be inside the final array. How is this, at least for a start?
我假设你的数组名为 $array。
I'll assume that your array is called $array.