Hi,
I didn't even think PHP would do anything until I just tried it.
?php
for ($i = A; $i = Z; $i++){
echo $i . br /;
}
?
outputs:
A
B
C
X
Y
Z
AA
AB
AY
AX
YA
YB
YY
YZ
Why it continues after Z is not clear to me, and why it doesn't continue
until ZZ isn't either.
MIGUEL ANTONIO GUIRAO AGUILAR wrote:
Hi!!
I wanna a do a for loop with letters, Is this possible?
for ($i = 'A'; $i = 'Z'; $i++){
// code
}
--
MIGUEL GUIRAO AGUILERA
Logistica R8 - Telcel
Tel: (999) 960.7994
Cel: 9931-6
No, but there are multiple ways this
hi Miguel
I wanna a do a for loop with letters, Is this possible?
for ($i = 'A'; $i = 'Z'; $i++){
// code
}
you can, but it doesn't do what you think it should do. Apparently it
gets to Z, restarts with AA, AB, AC etc and continues like that until it
hits YZ. feck knows why :-/
hth (a
Chris wrote:
You could create a string, loop through it's length, then access the $i
character in the string.
$sAlpha = 'ABCDEF...XYZ';
for($i=0;$i26;++$i)
{
$sLetter = $sAlpha{$i};
// code
}
range() is a powerful function for creating such strings. You don't
need to loop.
MIGUEL ANTONIO GUIRAO AGUILAR wrote:
Hi!!
I wanna a do a for loop with letters, Is this possible?
for ($i = 'A'; $i = 'Z'; $i++){
// code
}
try it.
php -r '
for ($i = a; $i z; $i++){ echo $i,.; } echo z;'
--
MIGUEL GUIRAO AGUILERA
Logistica R8 - Telcel
Tel:
try
for ($i =ord( 'A'); $i = ord('Z'); $i++){
// code
}
bastien
From: MIGUEL ANTONIO GUIRAO AGUILAR [EMAIL PROTECTED]
To: php-db@lists.php.net
Subject: [PHP-DB] Letters loop
Date: Wed, 25 May 2005 20:37:47 -0700
Hi!!
I wanna a do a for loop with letters, Is this possible?
for ($i = 'A';
@lists.php.net
Subject: RE: [PHP-DB] Letters loop
try
for ($i =ord( 'A'); $i = ord('Z'); $i++){
// code
}
bastien
From: MIGUEL ANTONIO GUIRAO AGUILAR [EMAIL PROTECTED]
To: php-db@lists.php.net
Subject: [PHP-DB] Letters loop
Date: Wed, 25 May 2005 20:37:47 -0700
Hi!!
I wanna a do a for loop
nope
chr ( int ascii ) takes the integer
ord ( string string ) takes the string
bastien
From: Miguel Guirao [EMAIL PROTECTED]
To: php-db@lists.php.net
Subject: RE: [PHP-DB] Letters loop
Date: Thu, 26 May 2005 09:22:56 -0500
Thanks!!
I think the ord() function should receive an integer
and it
returns it's corresponding character.
But it will work!!!
-Original Message-
From: Bastien Koert [mailto:[EMAIL PROTECTED]
Sent: Jueves, 26 de Mayo de 2005 08:28 a.m.
To: [EMAIL PROTECTED]; php-db@lists.php.net
Subject: RE: [PHP-DB] Letters loop
try
for ($i =ord( 'A'); $i = ord