Count on multidimensional array


Posted on 16th Feb 2014 07:03 pm by admin

Hi, i got an array as below:

Array
(
=> 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
(
=> 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

No comments posted yet

Your Answer:

Login to answer
52 Like 44 Dislike
Previous forums Next forums
Other forums

if statements problems
Hi. I'm trying to make a web form, but I kind of hit a dead end trying to figure out why it doesn't

Help with ORDER BY
Hello. I would like to order by ascending States, then Cities, then Gyms in the following code, but

upload only text files
hi guys i want to upload only text like like (pdf,note pad and ofiice files) so can any one please t

Send inserts to mysql thru port 80
Hi!

I have an application that must do some inserts in a mysql db. This db is behind a firewa

How to make a mail Form secure?
I want to create an email Form on my web site. How can I make the Form secure so the submitted info

Shuffle between users ??
I have multiple $users in table. I need to send them $message.

I need to send the next messag

Create a form of 2 numbers input and find the greatest.
Hi, everybody.

I have a homework in my training of php, which ask you to make a form that ask

C - Reading a file into a byte array
Hi,

I'm trying to read a file into a byte array in C. I have to use C as this is for a loadru

pass form variables straight to email, no database required?
hello all,

im working on this form...

http://www.adobedayevents.com/project_request/pr

ECC6 - Single sign-on
We are in the process of upgrading to ECC 6 which will support single sign on with user passwords al

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash