title: How Do I change every second elements class using PHP?
body: <p>I want to change the CSS class of every second element within an included partial. Here is a code example of the output I want:</p>
  
  <pre><code>&lt;p class="rec"&gt;&lt;/p&gt;
  &lt;p class="sent"&gt;&lt;/p&gt;
  &lt;p class="rec"&gt;&lt;/p&gt;
  &lt;p class="sent"&gt;&lt;/p&gt;
  </code></pre>
  
  <p>This is what I tried it so far:</p>
  
  <pre><code>&lt;?php $derp = (isset($derp) &amp;&amp; $derp == 'rec') ? 'sent' : 'rec'; ?&gt;
  &lt;p class='&lt;?php echo $derp; ?&gt;'&gt;
  //CONTENT
  &lt;/p&gt;
  </code></pre>
  
  <p>I need help to get this working. I don't want to use the <strong>nth-child</strong> selector or JavaScript to change the class.</p>
  
  <p>//update:</p>
  
  <pre><code>    @forelse($statuses as $status)
          @include('statuses.partials.status')
      @empty
      &lt;div class="notif blue"&gt;
          &lt;span&gt;This user hasn't yet posted a status.&lt;/span&gt;
          &lt;span class="icon icon-info-sign"&gt;&lt;/span&gt;
      &lt;/div&gt;
      @endforelse
  </code></pre>
  
  <p>The partial get looped like this.</p>