Jump to content

Count on multidimensional array


GaRd3NiA

Recommended Posts

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!!!

 

Link to comment
https://forums.phpfreaks.com/topic/185832-count-on-multidimensional-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.