按时间排序的$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
), ....
)
求教
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
), ....
)
求教
解决方案 »
- PHP生成excel文件并自動保存與另一服務器指定位置的解決方法
- Warning: mysql_fetch_array() expects parameter 1
- PHP查询数据库数据时出现错误
- while(mysql_fetch_array($result))问题
- DZ自动上传远程图片如何改成自动上传远程附件,熟悉DZ的高手帮忙一下
- header("Content-Disposition: attachment; filename=$filename");
- 招聘:大型网站建设人员!(上海)
- 请问:下面这个几行的小程序为何出错?
- 如何将mysql数据库里的数据转到access
- php 文件下载 兼容safari
- phpmail在windows测试可以,上传到ubuntu就不灵了。为什么啊
- 如何定位php语法错误,有专门的编译器吗?
[0] => array(
times => '2012-10-10',
type =>0,
num =>100
type =>1,
num =>400
),
[1] => array(
times => '2012-10-11',
type =>0,
num =>103
type2 =>1,
num2 =>403
),
....
)
times => '2012-10-10',
type =>0,
num =>100
type =>1,
num =>400
相同的键?这样的数组不可能出现,所以无解!
总不能让人家整理你的数据吧?
$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<$cnt;$i++){
$date2[$i]=array_merge($date[$i],$date1[$i]);
}
echo "<pre>";
print_r($date);
print_r($date1);
print_r($date2);
echo "</pre>";
//结果如下
Array
(
[0] => Array
(
[time] => 2012-11-10
[type0] => 0
[num0] => 100
) [1] => Array
(
[time] => 2012-11-11
[type0] => 0
[num0] => 103
))
Array
(
[0] => Array
(
[time] => 2012-11-10
[type1] => 1
[num1] => 105
) [1] => Array
(
[time] => 2012-11-11
[type1] => 1
[num1] => 120
))
Array
(
[0] => Array
(
[time] => 2012-11-10
[type0] => 0
[num0] => 100
[type1] => 1
[num1] => 105
) [1] => Array
(
[time] => 2012-11-11
[type0] => 0
[num0] => 103
[type1] => 1
[num1] => 120
))