How can I write this in such a way that $counter value is 1 on its first iteration and 0 on each following cycle?
$counter =1;
foreach($result):
$number = $result['value'] + $counter;
db->update($result['value'] => $number);
$counter--;
endforeach;
Essentially my goal is to get $number to be $number+1 on the first loop and then $number+0 for each following loop.
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.
I do not see where the problem resides.