title: Foreach loop add class depending on number
body: <p>I have managed to find answers close to what I require but I am still having an issue. I have based my code on the answer at <a href="https://stackoverflow.com/questions/6220546/count-number-of-iterations-in-a-foreach-loop">Count number of iterations in a foreach loop</a>.</p>
  
  <p>Basically, I want to add a class to a list item which appears in a foreach loop. The class that I want to add is to be based on the count of the list item. For example I want the out put to look like:</p>
  
  <pre><code>&lt;ul&gt;
    &lt;li class="item-1"&gt;&lt;/li&gt;
    &lt;li class="item-2"&gt;&lt;/li&gt;
    &lt;li class="item-3"&gt;&lt;/li&gt;
  &lt;ul&gt;
  </code></pre>
  
  <p>So far, my code looks like:</p>
  
  <pre><code>&lt;ul&gt;
  &lt;?php $i = 0; ?&gt;
  &lt;?php foreach($gallery as $count=&gt;$photo): ?&gt;
    &lt;?php $i++; ?&gt;
    &lt;li class="item-&lt;?php echo $count=&gt;$photo[number]; ?&gt;"&gt;&lt;/li&gt;
  &lt;?php endforeach; ?&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>The issue seems to be that I cannot use <code>&lt;?php echo $count=&gt;$photo[number]; ?&gt;</code>.</p>
  
  <p>Any help would be greatly appreciated.</p>