数组1
时间 GPS_flag
2010-08-01 1
2010-08-03 1数组2
时间 数量
2010-08-01 3
2010-08-02 4
2010-08-04 6合并结果
数组3
时间 GPS_flag 数量
2010-08-01 1 3
2010-08-02 4
2010-08-03 1
2010-08-04 6我想合并数组1,跟数组2,通过时间归并得到数组3,
最后遍历下数组3,能输出对应每条数据,比如输出:
<data time='2010-08-01' GPS_flag='1' 数量='3' />
<data time='2010-08-02' GPS_flag='0' 数量='4' />
<data time='2010-08-03' GPS_flag='1' 数量='0' />
<data time='2010-08-04' GPS_flag='0' 数量='5' />
没值的就为0输出谢谢师兄们帮忙!!!!
时间 GPS_flag
2010-08-01 1
2010-08-03 1数组2
时间 数量
2010-08-01 3
2010-08-02 4
2010-08-04 6合并结果
数组3
时间 GPS_flag 数量
2010-08-01 1 3
2010-08-02 4
2010-08-03 1
2010-08-04 6我想合并数组1,跟数组2,通过时间归并得到数组3,
最后遍历下数组3,能输出对应每条数据,比如输出:
<data time='2010-08-01' GPS_flag='1' 数量='3' />
<data time='2010-08-02' GPS_flag='0' 数量='4' />
<data time='2010-08-03' GPS_flag='1' 数量='0' />
<data time='2010-08-04' GPS_flag='0' 数量='5' />
没值的就为0输出谢谢师兄们帮忙!!!!
$arrB = array(array('2010-08-01', '3'), array('2010-08-02', '4'), array('2010-08-04', '6'));$res = array();
foreach($arrA AS $v)
{
$res[$v[0]] = array($v[1], 0);
}
foreach($arrB AS $v)
{
if(isset($res[$v[0]]))
{
$res[$v[0]][1] = $v[1];
}
else
{
$res[$v[0]] = array(0, $v[1]);
}
}
print_r($res);//其中时间保存在数组key中