2021年3月7日星期日

Concatenate 2 arrays by parts

I have two arrays. For example:

 $arr1 = [1, 2, 3, 7, 8, 9];   $arr2 = [4, 5, 6, 10, 11, 12, 13, 14];  

How can I combine them to general array by taking per 3 elements from every array? The output should be:

[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]  

The main idea is taking per 3 elements. Later when I understand the algorithm, the arrays will have objects, not digits. I need to understand how I can to combine two arrays by taking per 3 elements from every array.

Thanks

https://stackoverflow.com/questions/66523028/concatenate-2-arrays-by-parts March 08, 2021 at 08:43AM

没有评论:

发表评论