[
{
Name0: "TEST",
Value0: "13",
Timestamp0: "2012-01-02 00:00:13"
},
{
Name0: "TEST",
Value0: "16",
Timestamp0: "2012-01-02 00:10:45"
}
],
[
{
Name1: "TEST",
Value1: "30",
Timestamp1: "2012-01-02 00:00:13"
},
{
Name1: "TEST",
Value1: "60",
Timestamp1: "2012-01-02 00:10:45"
}
]
[
{
Name0: "TEST",
Value0: "13",
Timestamp0: "2012-01-02 00:00:13",
Name1: "TEST",
Value1: "30",
Timestamp1: "2012-01-02 00:00:13"
},
{
Name0: "TEST",
Value0: "16",
Timestamp0: "2012-01-02 00:10:45",
Name1: "TEST",
Value1: "60",
Timestamp1: "2012-01-02 00:10:45"
}
]
$loop_length = count($array[0]);
$new_array = array();
for($i=0; $i<$loop_length; $i++){
for($j=0; $j<count($array); $j++){
if(!array_key_exists($j,$new_array)) $new_array[$j] = array();
$new_array[$j] = array_merge($new_array[$j],$array[$i][$j]);
}
}
var_dump($new_array);
<?php
for ($i = 0; $i < count($array[0]); $i++) {
$array[0][$i] = array_merge($array[0][$i], $array[1][$i]);
}
$array = $array[0];
?>
<?php
$arr1 = array(array('name0' => 'foo', 'val0' => '10'),
array('name0' => 'cde', 'val0' => '11'));
$arr2 = array(array('name1' => 'bar', 'val1' => '20'),
array('name1' => 'fgh', 'val0' => '21'));
$arr_mrg = array();
for($i=0; $i<count($arr1); $i++){
$arr_mrg[$i] = array_merge($arr1[$i], $arr2[$i]);
}
var_dump($arr_mrg); //test output of the result
?>