如何创建一个循环以将数组更改为输出?
像这样的数组:
Array(
0=>google.com,
1=>microsoft.com,
2=>array(
google.com=>cloud,
microsoft.com=>office),
3=>array(
microsoft.com=>azur),
4=>array(
office=>array(
0=>word,
1=>exel)
)
)
我想创建一个循环以将数组更改为输出? (在PHP中)。所以结果就像 这: 输出:
array(
google.com=>array(0=>cloud),
microsoft.com=>array(
office=>array(0=>word , 1=exel),
azur)
)
My array like this:
Array(
0=>google.com,
1=>microsoft.com,
2=>array(
google.com=>cloud,
microsoft.com=>office),
3=>array(
microsoft.com=>azur),
4=>array(
office=>array(
0=>word,
1=>exel)
)
)
I want to create a loop to change the array to the output? (In PHP). So the result to be like
this:
The Output:
array(
google.com=>array(0=>cloud),
microsoft.com=>array(
office=>array(0=>word , 1=exel),
azur)
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
您的输入以及输出数据是一团糟,其中项可能是数组键或数组值。
无论如何,首先,我递归地将输入清楚地清楚为简单的
child_term => parent_term
数组。然后,我将此简单的地图转换为树形式:
Your input aswell as the output data is a mess where term might be an array key or an array value.
Anyways first of all I recursively plainify the input into a simple
child_term => parent_term
array.Then I convert this simple map into a tree form: