How to merge 2 arrays alternatively..?

@droopsnoot
Im using $arr1 and $arr2 arrays, then run a loop to combine them so that i get their values alternatively…

$arr1 = [1,3,5];
$arr2 = [2,4,6];
for()//since both are same length
{
 $array_combined=[1,2,3,4,5,6]; 
}

I saw that, I just wondered why you do the job twice. If you need to have the two separate arrays and the combined array later on in the code, then fair enough. If you are only building the two separate arrays as a step towards the combined one, it seems a waste of code to me.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.