2016-08-30 57 views
-2

我有一個數組看起來像這樣,我想通過相同的值合併數組。如何通過匹配值在php中合併數組?

 

[data_db] => Array 
    (
     [0] => Array 
      (
       [a_id] => 6 
       [a_number] => 50314 //account_type 
       [a_name] => John 
       [a_detail] => Monthly 
       [a_status] => 1 
      ) 
    ) 

[data_detail] => Array 
    (
     [0] => Array 
      (
       [d_Desc] => Promotion 
       [d_Balance] => 999918198 
       [d_Code] => 101 
       [d_Number] => 40314 //account_type 
      ) 

     [1] => Array 
      (
       [d_Desc] =>Promotion 
       [d_Balance] => 999918198 
       [d_Code] => 101 
       [d_Number] => 50314 //account_type 
      ) 

    ) 

如何合併這樣

 
[data_db] => Array 
    (
     [0] => Array 
      (
       [a_id] => 6 
       [a_number] => 50314 //account_type 
       [a_name] => John 
       [a_detail] => Monthly 
       [a_status] => 1 
       [d_Desc] =>Promotion 
       [d_Balance] => 999918198 
       [d_Code] => 101 
      ) 
    ) 

[data_detail] => Array 
    (
     [0] => Array 
      (
       [d_Desc] => Promotion 
       [d_Balance] => 999918198 
       [d_Code] => 101 
       [d_Number] => 40314 //account_type 
      ) 

     [1] => Array 
      (
       [d_Desc] =>Promotion 
       [d_Balance] => 999918198 
       [d_Code] => 101 
       [d_Number] => 50314 //account_type 
      ) 

    ) 

我試圖通過ACCOUNT_TYPE正如我上面的代碼標記合併到數組的數組。 我試過按照這個鏈接Merge array according to match column values in PHP,但對我來說似乎還不夠。

請給我建議或我可以繼續的鏈接。 謝謝

+0

花點時間閱讀幫助中心的[編輯幫助](http://stackoverflow.com/editing-help)。堆棧溢出的格式與其他站點不同。你的帖子看起來越好,其他人閱讀和理解它就越容易。 – Rizier123

+0

是'data_db'和'data_detail'兩個不同的數組,或者是同一個數組中的兩個鍵? –

+0

他們是在同一陣列 –

回答