If you take for , as you wrote, and simply replace $i++ with $i-- , the value of $i will decrease with each iteration (1, 0, -1, -2, etc.), and the loop condition $i<=10 always true.
If you want to count back, you also need to change other parts (initialization and looping condition):
for ($i=10; $i>=1; $i--){ echo $i; }
Or you take the last one and subtract the current value from it and add the first value to it:
for ($first=1, $i=$first, $last=10; $i<=$last; $i++){ echo $last - $i + $first; }
Gumbo
source share