Count on multidimensional array


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

Hi, i got an array as below:

Array
(
Did you know?Explore Trending and Topic pages for more stories like this.
=> 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

Lack of simpleXML Documentation
What is up with this.

Look at: http://www.php.net/manual/en/function.simplexml-load-file.php<

PHP5/Zend 2.0 - Resources
PHP5 Snapshots
http://snaps.php.net/

ZEND 2.0 Feature Overview and Design (PDF File

How to form a xml form table with a single sql statement..?
Hi everyone,
I don't know if this is going to be a duplicate thread but i couldn't

b+ tree
Hi
can every body help me about b+ tree ?(insert & delete)

Asset Transfer from One plant to another within same company code
Hi,

Please advise how to transfer one asset from one plant to another plant within same c

add to sql result
ok see rite now my sites hit counter is counted from the mysql visitor log i need to clear it aft

How do I send data using an html link
Hi

If I have
<a href="main_file.php">

How do I send data t

If statement help please.
Hello on my site I have 2 content boxes. 1 is for the main content (which is the biggest one) and th

How to use Ajax to verify data on a DB ?
Hello everyone, well i want to know how to check a value if it exists or not on a Data base and capt

contact form - output to page and email
I have the following in my controller:

$message['name'] = htmlentities(strip_tags(trim($_POST

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