Looping from A to Z

From: Date: Sun, 19 Feb 2006 23:24:31 +0000
Subject: Looping from A to Z
Groups: php.general 
Request: Send a blank email to php-general+get-230720@lists.php.net to get a copy of this message
Good afternoon. I'm having trouble getting PHP to loop from A through Z. Here is what I tried, coming from a C background: for ($l = "A"; $l <= "Z"; $l++)
     echo $l;
// Returns A, B, C, ..., X, Y, Z, AA, AB, AC, AD, AE, ... YX, YY, YZ. (26 * 26 results!) Interestingly, if I make it a "less than" operation instead of "less than or equal to", it works correctly (except for the Z): for ($l = "A"; $l < "Z"; $l++)
     echo $l;
// Returns A, B, C, ..., W, X, Y (25 results) Anyone know why PHP would do that? Richard --- Richard K. Miller www.richardkmiller.com

« previous php.general (#230720) next »