本文介绍了谈到多维数组转换成一维数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在敲打我的脑袋就这一个了一段时间。
I've been banging my head on this one for a while now.
我有这样的多维数组:
Array
(
[0] => Array
(
[0] => foo
[1] => bar
[2] => hello
)
[1] => Array
(
[0] => world
[1] => love
)
[2] => Array
(
[0] => stack
[1] => overflow
[2] => yep
[3] => man
)
和我需要这样的:
Array
(
[0] => foo
[1] => bar
[2] => hello
[3] => world
[4] => love
[5] => stack
[6] => overflow
[7] => yep
[8] => man
)
任何想法?
所有其他解决方案,我发现解决不同的密钥多维数组。我的阵列使用简单的数字键而已。
All other solutions I found solve multidimensional arrays with different keys. My arrays use simple numeric keys only.
推荐答案
解决方案:我用hakre的解决方案,尽管我试图deceze的解决方案也和它的工作原理也是如此。我写道:
SOLUTION: I used hakre's solution, even though I tried deceze's solution too and it works as well. I wrote:
$flat = call_user_func_array('array_merge', $array);
简单。
这篇关于谈到多维数组转换成一维数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!