title: Finding average of same key values of an associate array
body: <p>I've have an array such as </p>
  
  <pre><code>//$ary, $ary contains some 80 entries, I'm showing only the first 10
  Array
  (
      [0] =&gt; Array
          (
              [December 2012] =&gt; 58
          )
      [1] =&gt; Array
          (
              [November 2012] =&gt; 84
          )
      [2] =&gt; Array
          (
              [December 2012] =&gt; 83
          )
      [3] =&gt; Array
          (
              [November 2012] =&gt; 72
          )
      [4] =&gt; Array
          (
              [November 2012] =&gt; 47
          )
      [5] =&gt; Array
          (
              [December 2012] =&gt; 93
          )
      [6] =&gt; Array
          (
              [November 2012] =&gt; 79
          )
      [7] =&gt; Array
          (
              [October 2012] =&gt; 70
          )
      [8] =&gt; Array
          (
              [November 2012] =&gt; 75
          )
      [9] =&gt; Array
          (
              [October 2012] =&gt; 59
          )
      [10] =&gt; Array
          (
              [December 2012] =&gt; 67
          )
  )
  </code></pre>
  
  <p>I'm able to get the total for each month using:</p>
  
  <pre><code>foreach($ary as $array)
  {   
      foreach($array as $month=&gt;$cent)
      {
  
          if(isset($abc[$month])) // prevent index warning
          {           
              $abc[$month] += $cent;
             // tried using $abc[$month] = $abc[$month]/2 but wrong values were returned
          }
          else
          {
              $abc[$month] = $cent;
          }
      }
  }
  </code></pre>
  
  <p>This is resulting in </p>
  
  <pre><code>Array
  (
      [December 2012] =&gt; 2195
      [November 2012] =&gt; 2159
      [October 2012] =&gt; 1631
  )
  </code></pre>
  
  <p>But I'm unable to find a way to find the average value for each month. In my case, there are 31 instances of <code>December 2012</code>, 31 instances of <code>November 2012</code> and 25 instances of <code>October 2012</code>. Thus, I need to get hold of these <code>31</code>, <code>31</code>, and <code>25</code> values so that I can divide a month by that number.</p>
  
  <p>I'm thinking something must be done inside <code>if(isset($abc[$month]))</code> loop to capture but haven't been successful so far. Is there any other way to get the average?</p>
  
  <p>PS : I can't hardcode the month's name (October, November, December) for comparison purposes. They keep changing at regular intervals.</p>