php 合龙两个二维数组
程序员文章站
2024-04-04 18:39:05
...
php 合并两个二维数组
按时间排序的
两个数组times 是一样的,怎么把它们合并成
求教
------解决方案--------------------
楼主,就冲你那0的结贴率,呵呵。
按时间排序的
$data1 = array(
[0] => array(
times => '2012-10-10',
type =>0,
num =>100
),
[1] => array(
times => '2012-10-11',
type =>0,
num =>103
),
....
)
$data2 = array(
[0] => array(
times => '2012-10-10',
type =>1,
num =>400
),
[1] => array(
times => '2012-10-11',
type =>1,
num =>403
),
....
)
两个数组times 是一样的,怎么把它们合并成
$data = array(
[0] => array(
times => '2012-10-10',
type =>0,
num =>100
type =>1,
num =>400
),
[1] => array(
times => '2012-10-11',
type =>0,
num =>103
type =>1,
num =>403
),
....
)
求教
------解决方案--------------------
楼主,就冲你那0的结贴率,呵呵。
$date=array(array("time"=>"2012-11-10","type0"=>0,"num0"=>100),array("time"=>"2012-11-11","type0"=>0,"num0"=>103));
$date1=array(array("time"=>"2012-11-10","type1"=>1,"num1"=>105),array("time"=>"2012-11-11","type1"=>1,"num1"=>120));
$cnt=count($date);
for($i=0;$i $date2[$i]=array_merge($date[$i],$date1[$i]);
}
echo "";";
print_r($date);
print_r($date1);
print_r($date2);
echo "
//结果如下
Array
(
[0] => Array
(
[time] => 2012-11-10
[type0] => 0
[num0] => 100
)相关文章
相关视频