get the max number of these array's length,then use a temp array to reset the arrays.

解决方案 »

  1.   

    Do you understand what I mean???
    1.the max number is 4(C[1][0])
       so the temp array should be D[4][2]
    2.read array A and write to array D,array D should be:
    1  A
    2  B
    3  
    4
    then copy array D to cover array A,then you can get the correct array A;
    the same as array B,array C...
      

  2.   

    1.the max number is 4(C[1][0])这是什么意思?不明白
      

  3.   

    $ar = array_fill(1, 4, array('', ''));$A = array(
     array(1, 'A'),
     array(2, 'B'),
    );foreach($A as $v) {
      $ar[$v[0]] = $v;
    }
    print_r($ar);
      

  4.   

    xuzuning(唠叨):我如何才能知道$ar的最大值是4呢
      

  5.   

    一维长度不相同-----------------so you should get the max length as the length of these final arrays
      

  6.   

    get the max value of each array[1][0]
      

  7.   

    zeroleonhart:你的方法不对
    不同的数组中存在相同的元素,我要的新数组的max length不是简单的叠加长度,如果存在相同的元素,则相同元素只计算一次长度
      

  8.   


    本来写了个程序帮你解决的,不过运行时发现
    array_combine、array_diff_key、array_intersect_key都是php5的函数
    只好作罢,用这几个函数本来比较方便解决的另外这个是不是写错了?
    -------------------------------------------------
    4  F                //B[1][0] = '2'  B[1][1] = 'F'
    -------------------------------------------------BTW:我有个自定义函数,用来交换二位数组的两个维的    function swap($temp_array) {
        $KeyName1 = array_keys($temp_array);
        $KeyName2 = array_keys($temp_array[$KeyName1[0]]);
        
        for ($i=0;$i<count($KeyName1);$i++) {
         for ($j=0;$j<count($KeyName2);$j++) {
         $new_array["$KeyName2[$j]"]["$KeyName1[$i]"] = $temp_array["$KeyName1[$i]"]["$KeyName2[$j]"];
         }
         }
        return $new_array;
        }交换后,你用max($arrayName[0])就能求出该数组最大下标
    多个数组就再求一次所有最大下标的最大值其他就看着办吧
      

  9.   

    xuzuning(唠叨):我如何才能知道$ar的最大值是4呢
    --------------------------------------------get the max value of each array[1][0]------------------------------------------我要的新数组的max length不是简单的叠加长度--------------------------------------DO YOU REALLY UNDERSTAND WHAT I SAY ????
    DO YOU KNOW WHAT "MAX" MEANS ???
      

  10.   

    get the max value of array[x][0] of the primary arrays