2016-08-30 58 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

他们是在同一阵列 –

回答