RE: [PHP] ($a = 'a'; $a <= 'z'; $a++) invalid?

From: Date: Thu, 14 Dec 2000 22:16:04 +0000
Subject: RE: [PHP] ($a = 'a'; $a <= 'z'; $a++) invalid?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-30372@lists.php.net to get a copy of this message
> -----Original Message----- > From: Philip Olson [mailto:philip@theprojects.org] > Sent: Thursday, December 14, 2000 2:45 PM > To: php-general@lists.php.net > Subject: RE: [PHP] ($a = 'a'; $a <= 'z'; $a++) invalid? > > > Also, when it reaches : > > $a <= 'z' > z <= 'z' > > z is treated as integer so is less then 'z' ? Close, but no. <= means "less than or equal to." "z", treated as a string, is equal to "z", so the loop continues. $a = 'y' 'y' is less than or equal to 'z', so we increment $a, which becomes 'z' $a = 'z' 'z' is less than or equal to 'z', so we increment $a, which becomes 'aa' $a = 'aa' 'aa' is (alphabetically) less than or equal to 'z'... --- Mark Roedel | "The most valuable function performed by Systems Programmer | the federal government is entertainment" LeTourneau University | Longview, Texas, USA | -- Dave Barry

« previous php.general (#30372) next »