想象一下有几个数组结构(我展示了三个,但我希望尽可能灵活)
$array1 = array("red", "red", "red");
$array2 = array("green", "green", "green", "green");
$array3 = array("blue", "blue");
我需要将这些数组合并在一起并具有如下结构:
Array
(
[0] => red
[1] => green
[2] => blue
[3] => red
[4] => green
[5] => blue
[6] => red
[7] => green
[8] => green
)
这个想法是遍历所有数组并一个一个地合并元素,如果任何一个数组已经用完元素,循环应该正常继续,我不确定我是否在这里解释自己最好