incrementing not as expected
| From: | Philip Olson | Date: | Thu, 14 Dec 2000 00:33:13 +0000 |
| Subject: | incrementing not as expected | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-30224@lists.php.net to get a copy of this message | ||
Hi guys,
This is NOT possible (note: $a remains as a string) :
for ($a = 'a'; $a <= 'z'; $a++) {
$foo[] = $a;
}
Yet this does work nicely :
$l = 'a';
for ($a = 1; $a <= 26; $a++) {
$foo[] = $l++;
}
I'd like to know why exactly this is the case. The first route goes from
: 'a' to 'yz' , 675 values!
I suspect the issue is $string <= 'string' but i don't appreciate types
enough to know why exactly, just guesses. I've even gone crazy and tried
this too :
for ((string) $z = 'a'; (string) $z <= 'z'; (string) $z++) {
(string) $foo .= (string) $z;
}
Curiously confused,
Philip
--
Disclaimers : My code may not be perfectly efficient but it gets the job done.
It's called : "Learn through experience."