php 合并两个二维数组
按时间排序的
<br /> <br /> $data1 = array(<br /> <br /> [0] => array(<br /> times => '2012-10-10',<br /> type =>0,<br /> num =>100<br /> ),<br /> <br /> [1] => array(<br /> times => '2012-10-11',<br /> type =>0,<br /> num =>103<br /> ),<br /> <br /> ....<br /> <br /> )<br /> <br /> $data2 = array(<br /> <br /> [0] => array(<br /> times => '2012-10-10',<br /> type =>1,<br /> num =>400<br /> ),<br /> <br /> [1] => array(<br /> times => '2012-10-11',<br /> type =>1,<br /> num =>403<br /> ),<br /> <br /> ....<br /> <br /> )<br /> <br />
<br /> $data = array(<br /> <br /> [0] => array(<br /> times => '2012-10-10',<br /> type =>0,<br /> num =>100<br /> type =>1,<br /> num =>400<br /> ),<br /> <br /> [1] => array(<br /> times => '2012-10-11',<br /> type =>0,<br /> num =>103<br /> type =>1,<br /> num =>403<br /> ),<br /> <br /> ....<br /> <br /> )<br />
<br /> $date=array(array("time"=>"2012-11-10","type0"=>0,"num0"=>100),array("time"=>"2012-11-11","type0"=>0,"num0"=>103));<br /> $date1=array(array("time"=>"2012-11-10","type1"=>1,"num1"=>105),array("time"=>"2012-11-11","type1"=>1,"num1"=>120));<br /> $cnt=count($date);<br /> for($i=0;$i<$cnt;$i++){<br /> $date2[$i]=array_merge($date[$i],$date1[$i]);<br /> }<br /> echo "<pre class="brush:php;toolbar:false">";<br /> print_r($date);<br /> print_r($date1);<br /> print_r($date2);<br /> echo "