Limit counter value after first loop cycle
<p>How can I write this in such a way that $counter value is 1 on its first iteration and 0 on each following cycle?</p>

<pre><code>$counter =1;

foreach($result):

 $number = $result['value'] + $counter;

 db-&gt;update($result['value'] =&gt; $number);

 $counter--;

endforeach;
</code></pre>

<p>Essentially my goal is to get $number to be $number+1 on the first loop and then $number+0 for each following loop.</p>

<p>The value of $result['value'] will be set after the first loop to $number+1, so on the next cycle $result['value'] will be the needed unchanged value.</p>
