我有一個多維數組,並且如果它們具有相同的division_id但不同的post_page_id並且返回一個數組,其中包含每個分區的總值並取消其餘設置,則會嘗試合計觀衆總數。我試過雙foreach但它沒有工作。任何幫助?由於取消設置多維數組中的數組php
Array
(
[0] => Array
(
[id] => 1
[post_page_id] => 22130
[audience] => 276
[type] => facebook
[division_id] => 1
[tw_audience] =>
)
[1] => Array
(
[id] => 14
[post_page_id] => 22465
[audience] => 6
[type] => facebook
[division_id] => 1
[tw_audience] =>
)
[2] => Array
(
[id] => 2
[post_page_id] => 22189
[audience] => 175
[type] => twitter
[division_id] => 2
[tw_audience] =>
)
[3] => Array
(
[id] => 1
[post_page_id] => 23044
[audience] => 180
[type] => facebook
[division_id] => 2
[tw_audience] =>
)
)
所以我想輸出是這樣
Array
(
[0] => Array
(
[id] => 1
[post_page_id] => 22130, 22465
[audience] => 282
[type] => facebook
[division_id] => 1
[tw_audience] =>
)
[1] => Array
(
[id] => 2
[post_page_id] => 22189, 23044
[audience] => 180
[type] => twitter+facebook
[division_id] => 2
[tw_audience] => 175
)
)
你能提供一個你想要結果看起來像什麼樣子的例子嗎? – ilikesleeping 2014-12-01 23:14:32
剛剛編輯,基本上,我想合併數組,並總結觀衆,並取消合併。謝謝 – vic 2014-12-01 23:31:53