GaRd3NiA Posted December 21, 2009 Share Posted December 21, 2009 Hi, i got an array as below: Array ( [0] => Array ( [2009-12-08] => 1 ) [1] => Array ( [2009-12-07] => 1 ) [2] => Array ( [2009-12-04] => 1 ) [3] => Array ( [2009-12-03] => 10 ) [4] => Array ( [2009-12-02] => 10 ) [5] => Array ( [2009-12-01] => 10 ) [6] => Array ( [2009-12-10] => 6 ) [7] => Array ( [2009-12-08] => 5 ) [8] => Array ( [2009-12-07] => 10 ) [9] => Array ( [2009-12-04] => 1 ) [10] => Array ( [2009-12-02] => 3 ) [11] => Array ( [2009-12-01] => 10 ) ) i would like to do a sum on each date, and generate the below array: Array ( [0] => Array ( [2009-12-10] => 6 ) [1] => Array ( [2009-12-08] => 6 ) [2] => Array ( [2009-12-07] => 11 ) [3] => Array ( [2009-12-04] => 2 ) [4] => Array ( [2009-12-03] => 10 ) [6] => Array ( [2009-12-02] => 13 ) [6] => Array ( [2009-12-01] => 20 ) ) Any idea? Thanks in advance!!! Quote Link to comment https://forums.phpfreaks.com/topic/185832-count-on-multidimensional-array/ Share on other sites More sharing options...
salathe Posted December 21, 2009 Share Posted December 21, 2009 You could just foreach over the array and add the values up (into a new array) as you go. Have you tried anything like that? Quote Link to comment https://forums.phpfreaks.com/topic/185832-count-on-multidimensional-array/#findComment-981413 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.