title: Sum values of each key on multidimensional array
body: <p>I have a haystack that i wanna sum the values of each array separately. This is what i have:</p>
  
  <pre><code>Array //ALL THE HAYSTACK
  (
      [0] =&gt; Array //REPRESENTS MONTH 1
          (
              [0] =&gt; Array  //REPRESENTS WEEK 1
                  (
                      [week] =&gt; 1
                      [user1] =&gt; Array
                          (
                              [0] =&gt; Array
                                  (
                                      [sell] =&gt; value
                                      [cost] =&gt; value
                                      [gain] =&gt; value
                                  )
                          )
  
                      [user2] =&gt; Array
                          (
                              [0] =&gt; Array
                                  (
                                      [sell] =&gt; value
                                      [cost] =&gt; value
                                      [gain] =&gt; value
                                  )
                          )
  
                      [user3] =&gt; Array
                          (
                              [0] =&gt; Array
                                  (
                                      [sell] =&gt; value
                                      [cost] =&gt; value
                                      [gain] =&gt; value
                                  )
                          )
                  )
              //... MORE WEEKS
  
          [1] =&gt; Array //REPRESENTS MONTH 2
          ( //... ALL THE PROCCES ABOVE
  ) 
  </code></pre>
  
  <p>I'm trying use <code>foreach()</code> for every month and for every week, like this:</p>
  
  <pre><code>$result = $array('sell' =&gt; 0, 'cost' =&gt; 0, 'gain' =&gt; 0);
  foreach ($monthArray as $theMonth =&gt; $week){
      foreach ($week as $user){
          $result['sell'] +=  $user['user1'][0]['sell'];
          $result['sell'] +=  $user['user2'][0]['sell'];
          $result['sell'] +=  $user['user3'][0]['sell'];
  
          //...
  </code></pre>
  
  <p>But, when i print <code>$result</code> him SUM EVERY MONTHS, not the specific month that i want... </p>
  
  <p>I want sum every week, and every month. How can solve this?</p>