php array_merge looping or similar

时间:2017-08-05 12:18:57

标签: php array-merge

Asking for help here, cannot figure it out myself. Need to merge a dynamic number of arrays, but dont know how to loop the array_merge.

Right now it looks like this:

for($i=0;$<$icount;$i++){
$newContent[$i] = array_merge($content[0][$i], $content[1][$i], $content[2][$i], $content[3][$i]);
};// etc.. the numbers keeps growing.

This works, but i have to add arrays manually.

Tryed the answers from the topic of possible duplicate, but nothing gave me the result.

1 个答案:

答案 0 :(得分:0)

谢谢,在rus stackoverflaw上得到了答案。

answred

for($i=0;$<$icount;$i++){
    $newContent[] = call_user_func_array(
        'array_merge',
        array_column($content, $i)
    );
}