我有這樣通過去除相同鍵值簡化陣列
Array ( [0] => Array ( [vendor_id] => 2 [vendor_total_order] => 80 ) [1] => Array ( [vendor_id] => 2 [vendor_total_order] => 100 ) [2] => Array ( [vendor_id] => 1 [vendor_total_order] => 150 ) [3] => Array ( [vendor_id] => 3 [vendor_total_order] => 80 ) [4] => Array ( [vendor_id] => 5 [vendor_total_order] => 150 ) [5] => Array ( [vendor_id] => 1 [vendor_total_order] => 110 ) )
我想以這樣的方式,如果「VENDOR_ID」是相同的爲存在有積累/求和的兩個值,以簡化該陣列的陣列值應該被分配給'vendor_total_order'到'vendor_id'(基本上我們將刪除具有與重複值的總值相同的vendor_id的值)。
所以當我提供上述數組作爲輸入輸出應該類似於如下
Array ( [0] => Array ( [vendor_id] => 2 [vendor_total_order] => 180 ) [1] => Array ( [vendor_id] => 1 [vendor_total_order] => 260 ) [2] => Array ( [vendor_id] => 3 [vendor_total_order] => 80 ) [3] => Array ( [vendor_id] => 5 [vendor_total_order] => 150 ) )
我怎樣才能做到這一點?
http://stackoverflow.com/questions/4535002/remove-duplicate-keys-from-multidimensional-array看到此 – StaticVariable 2014-09-24 05:35:38
@static變量,我看到的鏈接。你能幫我理解這個解決方案將如何幫助我解決我的問題 – 2014-09-24 05:44:14