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

From: Date: Thu, 14 Dec 2000 22:19:55 +0000
Subject: RE: [PHP] ($a = 'a'; $a <= 'z'; $a++) invalid?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-30374@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:15 PM > To: Mark Roedel > Cc: php-general@lists.php.net > Subject: RE: [PHP] ($a = 'a'; $a <= 'z'; $a++) invalid? > > > Hey Mark, > > That is odd considering this works just fine : > > $letter = 'a'; > for ($a = 1; $a <= 26; $a++) { > $foo[] = $letter++; > } > > I don't see a difference in incrementing styles. The difference there is that you're not incrementing $letter past 'z'. If you modify your for() statement to make it execute once more, you'll see that the next value appended to your $foo array is 'aa'. Which I suppose if nothing else tells us that PHP behaves consistently when "incrementing" a string... The overall concept that's a little tough to make sense of is that $var++ is not necessarily greater than $var, if $var is a string. --- 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 (#30374) next »