php 从一组数组和合并节点中删除父级数组 [英] php Remove parent level array from set of arrays and merge nodes
本文介绍了php 从一组数组和合并节点中删除父级数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对操作数组很糟糕...鉴于这种结构,我想删除顶级数组并将所有子集合并到一个平面数组中:
I am terrible with manipulating arrays...given this structure I want to remove the top level array and merge all subsets into one flat array:
Array
(
[0] => Array
(
[0] => Array
(
[0] => hey.com
)
[1] => Array
(
[0] => you.com
)
)
[1] => Array
(
[0] => Array
(
[0] => this.com
)
[1] => Array
(
[0] => rocks.com
)
)
)
到所需的结构:
Array
(
[0] => hey.com
[1] => you.com
[2] => this.com
[3] => rocks.com
)
速度至关重要 - 我们将处理数十万个结果
Speed is essential - we will be dealing with hundreds of thousands of results
推荐答案
你可以使用 RecursiveArrayIterator
$it = new RecursiveIteratorIterator(new RecursiveArrayIterator($data));
$list = iterator_to_array($it,false);
var_dump($list);
输出
array (size=4)
0 => string 'hey.com' (length=7)
1 => string 'you.com' (length=7)
2 => string 'this.com' (length=8)
3 => string 'rocks.com' (length=9)
这篇关于php 从一组数组和合并节点中删除父级数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文