title: For each $i, $i++ display result
body: <p>I have a function that counts the number of variables equal to one other, I used the technique in php for each, with <code>$i = 1</code> and whenever they find <code>$i++</code>.
  My problem is that I would display the results, but now, if I have four results, it displays <code>1 2 3 4</code>.
  How do you display only the total result?</p>
  
  <p>PHP code :</p>
  
  <pre><code>if(!empty($myvar)) {
      $i = 1;
      foreach ($identity as $ent) { 
          if(($ent-&gt;name) === ($myvar-&gt;name)) {
              echo $i;
              $i++; 
          } 
      }
  }
  </code></pre>