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

Multidimensional Array into an Html table, help!
Hello all, I am new to HTML/PHP so any help would be great.

I have a multidimensional array f

mysql UNION | warning mysql_fetch_array !!
Code: <?php
$i = 0;
$query1="SELECT * FROM `products` WHERE `div

How could I combine these arrays??
Hello.. I'm trying to figure out a way to combine these first two arrays to get the last array..

Upload file and add HTML
Hey everyone,

I have a client has meeting agendas and minutes that should be posted online. I

Displaying image pathname instead of image
Hello

Im trying to upload and then display images from a mysql database - Its only basic and

phpMailer will not connect using SMTP
I am trying to use phpMailer with smtp:

Code: [Select]$mailer = new PHPMailer();
$mailer-&

unexpected T_VARIABLE error
Hey all! I'm getting an unexpected T_VARIABLE with the following function:

function getHighes

Passing JS to PHP
So I have the following
Code: <?php
getdetails(?><script type="text/

MySQL issue
I am taking sentences through a form on page. Then checking some condition and trying to insert them

Help with file_get_html
The following code gives the expected results:

<html>
<head&g

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