title: How to exclude items in foreach loop
body: <p>I'm trying to display a specific set of references on my laravel page by iterating through an foreach loop and styling odd and even iterations differently with @class loop odd / loop even.</p>
  <p>However I as I begin the foreach loop with an @if, only some make it into the loop while some are skipped, which messes up my odd / even (e.g. #1, #2 and #4 make it into the loop which means I have two elements styled with loop even.</p>
  <p>How can I skip the ones that don't make it into the loop so I can display the result with alternating styling?</p>
  <pre><code>@foreach ($references as $reference )
      @if(isset($reference['is_startpage']) 
          &amp;&amp; $reference['is_startpage'] != 1 
          &amp;&amp; isset($reference['content']['featured']) 
          &amp;&amp; $reference['content']['featured'] == 1)
  
          &lt;div @class([
                      'row py-5' =&gt; $loop-&gt;odd,
                      'row flex-row-reverse py-5'=&gt; $loop-&gt;even,
                      ])&gt;&lt;/div&gt;
      @endif
  @endforeach
  </code></pre>