将所有子阵列合并为一个 [英] Merge all sub arrays into one

查看:112
本文介绍了将所有子阵列合并为一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种将所有子数组合并为一个大数组的方法.

I'm looking to find a way to merge all child arrays into one large array.

array (
    [0] = 
         [0] = '0ARRAY',
         [1] = '1ARRAY'
    [1] = 
         [0] = '2ARRAY',
         [1] = '3ARRAY'
)

进入

array (
    [0] = '0ARRAY', [1] = '1ARRAY', [2] = '2ARRAY', [3] = '3ARRAY'
)

不使用array_merge($array[0],$array[1]),因为我不知道实际有多少个数组.因此,我将无法指定它们.

Without using array_merge($array[0],$array[1]) because I don't know how many arrays there actually are. So I wouldn't be able to specify them.

谢谢

推荐答案

如果只有两个级别的数组,则可以使用

If it's only two levels of array, you can use

$result = call_user_func_array('array_merge', $array);

只要$ array不完全为空,它应该可以工作

which should work as long as $array isn't completely empty

这篇关于将所有子阵列合并为一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆