Jump to content

Moving many arrays into columns in multidimensional array


lilya

Recommended Posts

Hello.

I wonder if someone could help me in the right direction with this. I have four (large) arrays:

 

array($key1,$key2,$key3....); //(keys are ints from 1,2..)
array($a1,$a2,$a3....); // ($a*,$b*,$c* are doubles)
array($b1,$b2,$b3....);
array($c1,$c2,$c3....);

 

 

//what I want:

 

$unsorted = array(
$sub1 = array($key1,$a1,$b1,$c1);
$sub2 = array($key2,$a2,$b2,$c2);
$sub3 = array($key3,$a3,$b3,$c3);
...
.
.
)

 

Many thanks

 

Lily

array($key1,$key2,$key3....); //(keys are ints from 1,2..)
array($a1,$a2,$a3....); // ($a*,$b*,$c* are doubles)
array($b1,$b2,$b3....);
array($c1,$c2,$c3....);

$unsorted = array(
$sub1 = array($key1,$a1,$b1,$c1);
$sub2 = array($key2,$a2,$b2,$c2);
$sub3 = array($key3,$a3,$b3,$c3);

)

 

$sub1[0] = $key_array[0];

$sub1[1] = $a_array[0];

$sub1[2] = $b_array[0];

$sub1[3]= $c_array[0];

 

$unsorted[0] = $sub1;

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.