Search code examples
phpcountloopsinverse

How to count inverse with for in php?


My Problem: I want to count inverse in the for loop.

This is the opposite of what I want to do:

for($i=1;$i<=10;$i++){
    echo $i;
}

If I put $i-- doesn't works (my server crashes).

Help meeee!

Best Regards, Adam


Solution

  • When you say $i-- crashes your server, did you change the initialization and condition for $i?

    for($i=10; $i>=1; $i--){
        echo $i;
    }