note 39640 modified in control-structures.for by vrana

From: Date: Thu, 05 Aug 2004 18:11:32 +0000
Subject: note 39640 modified in control-structures.for by vrana
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-74043@lists.php.net to get a copy of this message
For the purposes of outputing the alphabet, <?php for ($i="A"; $i <= "Z"; $i++) echo "$i<br>"; ?> will actually output A-Z, then begin again with AA, AB, etc. until it finishes with YZ. Similarly, <?php for ($i="A"; $i <= "ZZ"; $i++) echo "$i<br>"; ?> will output A-Z, AA, AB... ZZ, then begin again with AAA, AAB, AAC... up to ZYZ. Thus an alternative to timrosseel's example for outputting the alphabet is: <?php for ($i="A"; $i != "AA"; $i++) echo "$i<br>"; ?> --was-- For the purposes of outputing the alphabet, for ($i="A"; $i <= "Z"; $i++) echo "$i<br>"; will actually output A-Z, then begin again with AA, AB, etc. until it finishes with YZ. Similarly, for ($i="A"; $i <= "ZZ"; $i++) echo "$i<br>"; will output A-Z, AA, AB... ZZ, then begin again with AAA, AAB, AAC... up to ZYZ. Thus an alternative to timrosseel's example for outputting the alphabet is: for ($i="A"; $i != "AA"; $i++) echo "$i<br>"; http://php.net/manual/en/control-structures.for.php

« previous php.notes (#74043) next »