title: Adding count values in a temporary array
body: <p>I am counting the difference between two days in inside a foreach loop. </p>
  
  <pre><code>foreach ($result as $key =&gt; $value) {
      # code...
  
      //$temp[$value-&gt;user_id]=$value-&gt;user_id;
      $count_dates=daysBetween($value-&gt;user_source_history_added,$current_date);
      $tmp_array[$count_dates][] = $count_dates;
  }
  </code></pre>
  
  <p>On debugging tmp_array, I get something like this. </p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [0] =&gt; 0
              [1] =&gt; 0
              [2] =&gt; 0
              [3] =&gt; 0
              [4] =&gt; 0
              [5] =&gt; 0
              [6] =&gt; 0
          )
  
      [1] =&gt; Array
          (
              [0] =&gt; 1
          )
  
      [3] =&gt; Array
          (
              [0] =&gt; 3
              [1] =&gt; 3
              [2] =&gt; 3
              [3] =&gt; 3
          )
  )
  </code></pre>
  
  <p>Now I want to count the number of 0's, 1's, 2's, 3's, etc. So for now there are 7 0's and 1 1's and 4 3's. 
  How do I get the count of all these numbers and how do I limit it that I get only the count till Array 20??</p>
  
  <p>I tried this:</p>
  
  <pre><code>foreach($tmp_array as $tmp_val)
  {
      count($tmp_val)
  }
  </code></pre>
  
  <p>But I get the count of main array that is 3</p>