The following is a simplified version of my code:
for($n10 = 10; $n10 = 1; $n10--2{
echo $n10;
};
I want the number in the second paragraph to increment by 2 with each loop, e.g.
10, 8, 6, 4
Any help would be much appreciated. Thanks!
The last component can be seen like a block of code, so you can do the following...
for($index=10;$index > 0;$index-=2) {
echo $index;
}
The -=
is equivalent to $index = $index - 2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With