基于这些数据:
Array
(
[from] => Array
(
[0] => Array
(
[0] => 2015-08-23 15:33:14
[1] => 2015-08-23 15:38:01
)
[1] => Array
(
[0] => 2015-08-23 09:39:23
[1] => 2015-08-23 15:44:23
)
)
[to] => Array
(
[0] => Array
(
[0] => 2015-08-23 15:38:01
[1] => 2015-08-23 15:42:22
)
[1] => Array
(
[0] => 2015-08-23 15:44:23
[1] => 2015-08-23 18:15:38
)
)
)
我需要这样的结果:array [from] [0] [0]与array [to] [0] [0]结合作为数组[0] [0]
[0] => Array
(
[0] => Array
(
[from] => 2015-08-23 15:33:14
[to] => 2015-08-23 15:38:01
)
...
)
...
我尝试了很多循环(它太丑了)我怀疑当大量数据时性能不好
答案 0 :(得分:2)
我认为这样可以解决问题。
$count1 = count($data);
$result = array();
for($i = 0; $i < $count1; $i++) {
$count2 = count($data['from'][$i]);
for($j = 0; $j < $count2; $j++) {
$result[$i][$j] = array(
"from" => $data['from'][$i][$j],
"to" => $data['to'][$i][$j]
);
}
}