Jump to content

Adding Arrays


Nodral

Recommended Posts

Hi

 

I have the following multidimensional array.

 

array => [0]

              ([apples]=>5,

                [pears]=>3,

                [bananas]=>6)

              [1]

              ([apples]=>2,

                [pears]=>4,

                [bananas]=>1)

              [2]

              ([apples]=>8,

                [bananas]=>2)

 

How can I iterate through it and produce one array with all the totals added up?

eg

array =>

              [apples]=>15,

                [pears]=>7,

                [bananas]=>9

 

I've tried googling , but can't seem to find the right thing.

Obviously these are example values, the arrays I'm using contain about 40 keys each, therefore this was easier to write / explain.

               

Link to comment
https://forums.phpfreaks.com/topic/266805-adding-arrays/
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.