如何“变平"一个多维数组到 PHP 中的简单数组?
问题描述
这可能是初学者的问题,但我已经阅读了较长时间的文档,但找不到任何解决方案.我想我可以对每个维度使用 implode,然后将这些字符串与 str_split
重新组合在一起以创建新的简单数组.但是我永远不知道连接模式是否也在值中,所以在执行 str_split
之后,我的原始值可能会中断.
It's probably beginner question but I'm going through documentation for longer time already and I can't find any solution. I thought I could use implode for each dimension and then put those strings back together with str_split
to make new simple array. However I never know if the join pattern isn't also in values and so after doing str_split
my original values could break.
对于多维数组内部的数组,是否有类似 combine($array1, $array2)
的东西?
Is there something like combine($array1, $array2)
for arrays inside of multi-dimensional array?
推荐答案
使用array_walk_recursive
使用 PHP 5.5.9-1ubuntu4.24 (cli) 测试(构建时间:2018 年 3 月 16 日 12:32:06)
Tested with PHP 5.5.9-1ubuntu4.24 (cli) (built: Mar 16 2018 12:32:06)
这篇关于如何“变平"一个多维数组到 PHP 中的简单数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!