I have 2 multidimentional arrays:
array1[0][0] = 'yes';
array1[0][1] = 'no';
array1[1][0] = 'gilbert';
array1[1][1] = 'duncan';
and
array2[0][0] = 'good';
array2[0][1] = 'bad';
array2[1][0] = 'vegetables';
array2[1][1] = 'chocolate';
I want to create a new array from this 2 arrays such that:
array3[0][0] = 'yes';
array3[0][1] = 'no';
array3[0][2] = 'good';
array3[0][3] = 'bad';
array3[1][0] = 'gilbert';
array3[1][1] = 'duncan';
array3[1][2] = 'vegetables';
array3[1][3] = 'chocolate';
I am using PHP. How do I achieve this. PHP array_merge() appends one array to another. What I want is to create a new array with the two arrays side by side.
You’ll need to just walk them. You’ve defined a fairly specific (and interesting) way of merging them. I’d probably recommend a function like this: