Im not sure what function to search for in regards to this so cant seem to help myself. Seems like an obvious problem really.
I have an array, and where I have duplicate keys, I wish to add the values. e.g:
This is a section of my array.
[1] => Array
(
[inputAvg] => 21.41 KB
[outputAvg] => 22.03 KB
[date] => 2011-08-01
)
[2] => Array
(
[inputAvg] => 182.63 KB
[outputAvg] => 186.05 KB
[date] => 2011-08-01
)
[3] => Array
(
[inputAvg] => 182.63 KB
[outputAvg] => 186.05 KB
[date] => 2011-08-02
)
[4] => Array
(
[inputAvg] => 4.84 MB
[outputAvg] => 4.93 MB
[date] => 2011-08-03
)
All I wish to do is, say where the date key of the array is the same (e.g. here 2011-08-01) I want to show this date once, but with combined values of the duplicate item....?
e.g
[1] => Array
(
[inputAvg] => 204.04 KB
[outputAvg] => 208.08 KB
[date] => 2011-08-01
)
[2] => Array
(
[inputAvg] => 182.63 KB
[outputAvg] => 186.05 KB
[date] => 2011-08-02
)
[3] => Array
(
[inputAvg] => 4.84 MB
[outputAvg] => 4.93 MB
[date] => 2011-08-03
)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…