Very easy question

I apologize in advance for the noobish question but i just can’t get it. I am getting back into php after 4 years.

I got the code to count up from 1 to 10. However I can’t figure out why I can’t count down?

My noobish code:

$number = 10;
while ($number >= 1) {
    echo "$number ";
    $number - 1;
}

Thanks for your help!


$number = 10;
while ($number >= 1) {
    echo $number--;
} 

Thank you, but why is mine bad?

Well because $number-1 returns a new value. It doesn’t alter the existing number.

You might have been thinking of $number -= 1; which is equivalent to $number–; or $number = $number - 1;.

You want an Assignment Operator, not an Arithmetic one.