2012-06-11 77 views
0

我怎樣才能使與集關聯數組結合?CakePHP的從組結果使合併關聯數組

我與合併管理,以使與指標,我剛纔的foreach troughout結果和所有3個數組合併成一個數組,但不是關聯數組,我可以結合辦呢?

例子:

Array 
(
    [0] => Array 
     (
      [0] => Array 
       (
        [Year] => 2003 
        [Month] => June 
        [MyCount] => 1 
       ) 

      [MyData1] => Array 
       (
        [type] => 10 
       ) 

      [MyData2] => Array 
       (
        [status] => 1 
       ) 

     ) 

    [1] => Array 
     (

      [0] => Array 
       (
        [Year] => 2003 
        [Month] => June 
        [MyCount] => 32 
       ) 

      [MyData1] => Array 
       (
        [type] => 7 
       ) 

      [MyData2] => Array 
       (
        [status] => 21 
       ) 

     ) 

) 

我怎樣才能使之成爲這樣的:

Array 
    (
     [0] => Array 
      (
       ['SomeName'] => Array 
        (
         [Year] => 2003 
         [Month] => June 
         [MyCount] => 1 
         [type] => 10 
         [status] => 1 
        ) 

      ) 

     [1] => Array 
      (

       ['SomeName'] => Array 
        (
         [Year] => 2003 
         [Month] => June 
         [MyCount] => 32 
         [type] => 7 
         [status] => 21 
        ) 

      ) 

    ) 

回答

3

試試這個

$a_final =array(); 
foreach($final as $data) 
{ 
    $a_final[]['SomeName'] = array('Year' => $data[0]['year'], 
           'Month' => $data[0]['Month'], 
           'MyCount' => $data[0]['MyCount'], 
           'type' => $data['MyData1']['type'], 
           'status' => $data['MyData2']['status']); 
} 
+0

是你的權利,我可以做到這樣。 TNX – user147