按时间排序的$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
    ),  ....
       
)
求教

解决方案 »

  1.   

    发的急了,合并后的数组,后边名字可以换下$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
            type2 =>1,
            num2 =>403
        ),
     
      ....
            
    )
      

  2.   

        [0] => array(
            times => '2012-10-10',
            type =>0,
            num =>100
            type =>1,
            num =>400
    相同的键?这样的数组不可能出现,所以无解!
      

  3.   

    按#1的补充,可以以times做键,逐个数组抄写进去
      

  4.   

    你贴出 var_export 打印的数据
    总不能让人家整理你的数据吧?
      

  5.   

    楼主,就冲你那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<$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
            ))