Jump to content

Ciclo for regressivo


jonhyhvaftn
Go to solution Solved by pwseo,

Recommended Posts

Bem, deu-me uma branca daquelas complicadas...

Basicamente quero fazer um ciclo for regressivo, em que comece no numero 2016 e termine no 2005.

Ao tentar fazer não consegui e fui pesquisar na net. Depois de alguns minutos nada achei, parece que só fazem progressivos e nunca regressivos.

Tentei a seguinte maneira, parecia-me a mais óbvia:

$current = date("Y");
for ($i = $current; $i < 2005; $i--) {
   echo $i;
}

Alguém me pode ajudar?

Edited by pwseo
indent.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.