title: Count the number of occurences of a particular value inside loop
body: <p>In array count all true where category is 1 after counting the category will move to 2 thn count all true and so on?</p>
  
  <p>Array generated:</p>
  
  <pre><code>foreach($_POST as $key =&gt; $data)
  {
      $a = explode("_", $key);
  
      $f = array(
          'category' =&gt; $a[1],
          'answer' =&gt; $data
      );
     $f_data[] = $f;
  }
  </code></pre>
  
  <p><strong>FROM</strong></p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
          )
  
      [1] =&gt; Array
          (
              [category] =&gt; 1
              [answer] =&gt; true
          )
  
      [2] =&gt; Array
          (
              [category] =&gt; 1
              [answer] =&gt; true
          )
  
      [3] =&gt; Array
          (
              [category] =&gt; 1
              [answer] =&gt; true
          )
  
      [4] =&gt; Array
          (
              [category] =&gt; 1
              [answer] =&gt; false
          )
  
      [5] =&gt; Array
          (
              [category] =&gt; 1
              [answer] =&gt; false
          )
  
      [6] =&gt; Array
          (
              [category] =&gt; 1
              [answer] =&gt; true
          )
  
      [7] =&gt; Array
          (
              [category] =&gt; 1
              [answer] =&gt; true
          )
  
      [8] =&gt; Array
          (
              [category] =&gt; 2
              [answer] =&gt; true
          )
  
      [9] =&gt; Array
          (
              [category] =&gt; 2
              [answer] =&gt; true
          )
  
      [10] =&gt; Array
          (
              [category] =&gt; 2
              [answer] =&gt; true
          )
  
      [11] =&gt; Array
          (
              [category] =&gt; 2
              [answer] =&gt; false
          )
  
      [12] =&gt; Array
          (
              [category] =&gt; 2
              [answer] =&gt; true
          )
  
      [13] =&gt; Array
          (
              [category] =&gt; 2
              [answer] =&gt; true
          )
  
  )
  </code></pre>
  
  <p><strong>To</strong></p>
  
  <pre><code>array (
     category: 1,
     count: 5
  ),
  array(
    category: 2,
    count: 5
  )
  </code></pre>