Q:

How to group multidimensional array by more keys

this is my array source.
//array for all reception
    $reception = array(
        array('code'=>'AB202','order'=>'111111','qty'=>'50.000'),
        array('code'=>'AB202','order'=>'111111','qty'=>'50.000'),
        array('code'=>'AB202','order'=>'222222','qty'=>'50.000'),
        array('code'=>'AB300','order'=>'666666','qty'=>'100.000'),
        array('code'=>'AB300','order'=>'666666','qty'=>'120.000'),
        array('code'=>'AB300','order'=>'777777','qty'=>'120.000')          
        );

the code AB202 equals order 111111 AND 222222
the order 111111 equals qty=>50, qty=>50
the order 222222 equals qty=>50
the code AB300 equals order 666666 AND 777777
the order 666666 equals qty=>100, qty=>120
the order 777777 equals qty=>120
I want group by code and order like this
Array
(
  [AB202] => Array    //array code
    (
      [111111] => Array     //array order
          (         
              [0] => 50.000    // qty
              [1] => 50.000
          )
      [222222] => Array
          (         
              [0] => 50.000
          ) 
    )

    [AB300] => Array
    (
      [666666] => Array
          (         
              [0] => 100.000
              [1] => 120.000
          )
      [777777] => Array
          (         
              [0] => 120.000
          ) 
    )

)

A:

loop thru all receptions, then check if code key or order key exists, make one if not, then append each qty
$newArr = array();
foreach ($reception as $code) {
    if (!array_key_exists($code['code'], $newArr)){
        $newArr[$code['code']] = array();
    }
    if (!array_key_exists($code['order'], $newArr[$code['code']])) {
        $newArr[$code['code']][$code['order']] = array();
    }
    array_push($newArr[$code['code']][$code['order']], $code['qty']);
}

