RE: [PHP] ($a = 'a'; $a <= 'z'; $a++) invalid?
| From: | Mark Roedel | Date: | Thu, 14 Dec 2000 19:56:56 +0000 |
| Subject: | RE: [PHP] ($a = 'a'; $a <= 'z'; $a++) invalid? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-30351@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Philip Olson [mailto:philip@theprojects.org]
> Sent: Thursday, December 14, 2000 1:10 PM
> To: Layne Weathers
> Cc: php-general@lists.php.net
> Subject: RE: [PHP] ($a = 'a'; $a <= 'z'; $a++) invalid?
>
>
> That is not my question. I want to know why it's doing what it's doing.
> not an alternative method -- there are many ways to reach this specific
> goal but that's not the point. The provided link showed other alternative
> methods.
My attempt at an explanation:
In two of the three components of the statement in question, you're treating
$a as a string variable ($a='a', and $a<='z'). In the third, you're
treating it as an integer by attempting to increment it.
The result is, obviously, not intuitive. At the same time, I'm not
altogether sure how it would be appropriately corrected. (That is, what
*should" be one greater than "z"? The current behavior, apparently, is that
"aa" comes next, and "aa" is, alphabetically speaking, less than
"z"...)
---
Mark Roedel | "The most valuable function performed by
Systems Programmer | the federal government is entertainment"
LeTourneau University |
Longview, Texas, USA | -- Dave Barry