title: How can I use a foreach loop and set small variations at fixed positions?
body: <p>I already search for long time on this forum and I can't find a solution to this problem.</p>
  
  <p>I need to create a <code>foreach</code> loop for 12 elements but 3 of them have different class.</p>
  
  <p>This is what I have done so far:</p>
  
  <pre><code>$result = $db-&gt;query("SELECT `views` FROM `views` WHERE `views` = `id` AND DATE_SUB(CURDATE(),INTERVAL 7 DAY) &lt;= date(`views`.`time`) ORDER BY `id` DESC LIMIT 12");
  
  while($row = $result-&gt;fetch_assoc()) {
      $users[] = $row;
  }
  
  $output .= '&lt;ul&gt;';
  foreach($rows as $row) {
      $output .= '&lt;li class="grid__item"&gt;&lt;/li&gt;';
  }
  $output .= '&lt;ul&gt;';
  
  return $output;
  </code></pre>
  
  <p>How can I add a different class to <code>li</code> objects at 2, 8 and 12 position?</p>
  
  <p>To output something like this:</p>
  
  <pre><code>&lt;ul&gt;                    
      &lt;li class="grid__item"&gt;&lt;/li&gt;
      &lt;li class="grid__item grid__item--deco grid__item--deco-1"&gt;&lt;/li&gt;
      &lt;li class="grid__item"&gt;&lt;/li&gt;
      &lt;li class="grid__item"&gt;&lt;/li&gt;
      &lt;li class="grid__item"&gt;&lt;/li&gt;
      &lt;li class="grid__item"&gt;&lt;/li&gt;
      &lt;li class="grid__item"&gt;&lt;/li&gt;
      &lt;li class="grid__item grid__item--deco grid__item--deco-2"&gt;&lt;/li&gt;
      &lt;li class="grid__item"&gt;&lt;/li&gt;
      &lt;li class="grid__item"&gt;&lt;/li&gt;
      &lt;li class="grid__item"&gt;&lt;/li&gt;
      &lt;li class="grid__item grid__item--deco grid__item--deco-3"&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>