Ask a Question related to PHP Development, Design and Development.
-
nyso #1
amazing for loop
Hi all,
I tried this :
for( $i = 'M' ; $i <= 'Y' ; $i++) {
$alpha_2 .= $i." " ;
}
I get :
M N O P Q R S T U V W X Y
=> no problem
BUT !
Try this :
for( $i = 'M' ; $i <= 'X' ; $i++) {
$alpha_2 .= $i." " ;
}
I get :
M N O P Q R S T U V W X Y Z AA AB AC AD
AE AF AG AH AI AJ AK AL AM AN AO AP AQ AR AS
AT AU AV AW AX AY AZ BA BB BC BD BE BF BG BH
BI BJ BK BL BM BN BO BP BQ BR BS BT BU BV BW
BX BY BZ CA CB CC CD CE CF CG CH CI CJ CK CL
CM CN CO CP CQ CR CS CT CU CV CW CX CY CZ DA
DB DC DD DE DF DG DH DI DJ DK DL DM DN DO DP
DQ DR DS DT DU DV DW DX DY DZ EA EB EC ED EE
EF EG EH EI EJ EK EL EM EN EO EP EQ ER ES ET
EU EV EW EX EY EZ FA FB FC FD FE FF FG FH FI
FJ FK FL FM FN FO FP FQ FR FS FT FU FV FW FX
FY FZ GA GB GC GD GE GF GG GH GI GJ GK GL GM
GN GO GP GQ GR GS GT GU GV GW GX GY GZ HA HB
HC HD HE HF HG HH HI HJ HK HL HM HN HO HP HQ
HR HS HT HU HV HW HX HY HZ IA IB IC ID IE IF
IG IH II IJ IK IL IM IN IO IP IQ IR IS IT IU
IV IW IX IY IZ JA JB JC JD JE JF JG JH JI JJ
JK JL JM JN JO JP JQ JR JS JT JU JV JW JX JY
JZ KA KB KC KD KE KF KG KH KI KJ KK KL KM KN
KO KP KQ KR KS KT KU KV KW KX KY KZ LA LB LC
LD LE LF LG LH LI LJ LK LL LM LN LO LP LQ LR
LS LT LU LV LW LX LY LZ MA MB MC MD ME MF MG
MH MI MJ MK ML MM MN MO MP MQ MR MS MT MU MV
MW MX MY MZ NA NB NC ND NE NF NG NH NI NJ NK
NL NM NN NO NP NQ NR NS NT NU NV NW NX NY NZ
OA OB OC OD OE OF OG OH OI OJ OK OL OM ON OO
OP OQ OR OS OT OU OV OW OX OY OZ PA PB PC PD
PE PF PG PH PI PJ PK PL PM PN PO PP PQ PR PS
PT PU PV PW PX PY PZ QA QB QC QD QE QF QG QH
QI QJ QK QL QM QN QO QP QQ QR QS QT QU QV QW
QX QY QZ RA RB RC RD RE RF RG RH RI RJ RK RL
RM RN RO RP RQ RR RS RT RU RV RW RX RY RZ SA
SB SC SD SE SF SG SH SI SJ SK SL SM SN SO SP
SQ SR SS ST SU SV SW SX SY SZ TA TB TC TD TE
TF TG TH TI TJ TK TL TM TN TO TP TQ TR TS TT
TU TV TW TX TY TZ UA UB UC UD UE UF UG UH UI
UJ UK UL UM UN UO UP UQ UR US UT UU UV UW UX
UY UZ VA VB VC VD VE VF VG VH VI VJ VK VL VM
VN VO VP VQ VR VS VT VU VV VW VX VY VZ WA WB
WC WD WE WF WG WH WI WJ WK WL WM WN WO WP WQ
WR WS WT WU WV WW WX WY WZ XA XB XC XD XE XF
XG XH XI XJ XK XL XM XN XO XP XQ XR XS XT XU
XV XW XX XY XZ YA YB YC YD YE YF YG YH YI YJ
YK YL YM YN YO YP YQ YR YS YT YU YV YW YX YY
YZ
=> hum... what's the problem ?
any idea ?
thanks in advance,
--
nyso
nyso Guest
-
! Amazing Jobs
Check this out : http://linkbee.com/AJEG -
The amazing repeating event!
Okay, I'm still working on the problem I've been on for three days. I have a call to main.asc and it returns a string. (I only care that it... -
Oh my god... this is absolutely AMAZING Flash...
Eminem's latest video is entirely in Flash ... unfreaking believable. Regardless of whether you like his music, you owe it to yourself as a Flash... -
Amazing effect
Right i was just looking through some web sites and this effect cought my eye which i would like to know how to make!!! If you go to... -
AMAZING FLASH!
I think mine is pretty good. If you want a continually updated list of the best around go to... http://www.favouritewebsiteawards.com/home.html ... -
nyso #2
Re: amazing for loop - erratum
> for( $i = 'M' ; $i <= 'X' ; $i++) {
I meant :> $alpha_2 .= $i." " ;
> }sorry !> for( $i = 'M' ; $i <= 'Z' ; $i++) {
--
nyso
nyso Guest
-
Alvaro G Vicario #3
Re: amazing for loop
*** nyso wrote/escribió (Thu, 20 Nov 2003 09:56:27 +0100):
'X' <= 'Y' ? --> true> for( $i = 'M' ; $i <= 'Y' ; $i++) {
'Y' <= 'Y' ? --> true
'Z' <= 'Y' ? --> false --> end
'X' <= 'Z' ? --> true
'Y' <= 'Z' ? --> true
'Z' <= 'Z' ? --> true
'AA' <= 'Z' ? --> true
'AB' <= 'Z' ? --> true
....
'YY' <= 'Z' ? --> true
'YZ' <= 'Z' ? --> true
'ZA' <= 'Z' ? --> false --> end
Please note you aren't comparing numbers but strings.
--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Alvaro G Vicario Guest
-
David Mackenzie #4
Re: amazing for loop
On Thu, 20 Nov 2003 11:48:31 +0100, Alvaro G Vicario
<alvaro_QUITAR_REMOVE@telecomputeronline.com> wrote:
It is interesting to see that PHP considers 'Z' + 1 == 'AA', though.>*** nyso wrote/escribió (Thu, 20 Nov 2003 09:56:27 +0100):>>> for( $i = 'M' ; $i <= 'Y' ; $i++) {
>'X' <= 'Y' ? --> true
>'Y' <= 'Y' ? --> true
>'Z' <= 'Y' ? --> false --> end
>
>'X' <= 'Z' ? --> true
>'Y' <= 'Z' ? --> true
>'Z' <= 'Z' ? --> true
>'AA' <= 'Z' ? --> true
>'AB' <= 'Z' ? --> true
>...
>'YY' <= 'Z' ? --> true
>'YZ' <= 'Z' ? --> true
>'ZA' <= 'Z' ? --> false --> end
>
>Please note you aren't comparing numbers but strings.
--
David ( @priz.co.uk )
The Internet Prisoner Database: [url]http://www.priz.co.uk/ipdb/[/url]
The Tarbrax Chronicle: [url]http://www.tarbraxchronicle.com/[/url]
David Mackenzie Guest
-
Justin Koivisto #5
Re: amazing for loop
David Mackenzie wrote:
Interesting yes, but I think that it is nice that PHP doesn't base> It is interesting to see that PHP considers 'Z' + 1 == 'AA', though.
incrementing a string solely on the ASCII value. Afterall, I think that
the following is a natural progression..
A,B...
Y,Z,AA,AB...
AY,AZ,BA,BB...
ZY,ZZ,AAA...
Afterall, when incrementing a character by adding int(1) to it, you are
simply increasing the ASCII value. After "Z" (chr(90)) would be "["
(chr(91)).
Also beware that ord('AA') will return 65 since it returns the ASCII
value of the *first* character of the string.
--
Justin Koivisto - [email]spam@koivi.com[/email]
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.
Justin Koivisto Guest
-
David Mackenzie #6
Re: amazing for loop
On Thu, 20 Nov 2003 15:12:51 GMT, Justin Koivisto <spam@koivi.com>
wrote:
I've just noticed that it is following exactly the same algorithm as>David Mackenzie wrote:>>> It is interesting to see that PHP considers 'Z' + 1 == 'AA', though.
>Interesting yes, but I think that it is nice that PHP doesn't base
>incrementing a string solely on the ASCII value. Afterall, I think that
>the following is a natural progression..
>
>A,B...
>Y,Z,AA,AB...
>AY,AZ,BA,BB...
>ZY,ZZ,AAA...
for incrementing "numeric" strings ("8", "9", "10", "11") except using
ASCII ranges 65..90 as opposed to 48..57.
I was once writing a function to concatenate date parts together
(before I discovered the date functions). I had:
$day = 19;
$month = "March";
$year = 1928;
The result of
$date = $day." ".$month." ".$year;
was
$date == "1947 March"
It added 19 and 1928, but preserved "March".
--
David ( @priz.co.uk )
The Internet Prisoner Database: [url]http://www.priz.co.uk/ipdb/[/url]
The Tarbrax Chronicle: [url]http://www.tarbraxchronicle.com/[/url]
David Mackenzie Guest
-
Alvaro G Vicario #7
Re: amazing for loop
*** David Mackenzie wrote/escribió (Thu, 20 Nov 2003 11:36:54 +0000):
It is curious indeed. It's documented anyway:> It is interesting to see that PHP considers 'Z' + 1 == 'AA', though.
«PHP follows Perl's convention when dealing with arithmetic operations on
character variables and not C's. For example, in Perl 'Z'+1 turns into
'AA', while in C 'Z'+1 turns into '[' ( ord('Z') == 90, ord('[') == 91 ).
Note that character variables can be incremented but not decremented.»
[url]http://us2.php.net/manual/en/language.operators.increment.php[/url]
(Nope, I didn't know until today ;-)
--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Alvaro G Vicario Guest
-
Default User #8
Re: amazing for loop
Alvaro G Vicario wrote:
>
> *** David Mackenzie wrote/escribió (Thu, 20 Nov 2003 11:36:54 +0000):>> > It is interesting to see that PHP considers 'Z' + 1 == 'AA', though.
> It is curious indeed. It's documented anyway:
>
> «PHP follows Perl's convention when dealing with arithmetic operations on
> character variables and not C's. For example, in Perl 'Z'+1 turns into
> 'AA', while in C 'Z'+1 turns into '[' ( ord('Z') == 90, ord('[') == 91 ).
> Note that character variables can be incremented but not decremented.»
Actually, C guarantees nothing of the sort. It does not require the use
of the ASCII character set at all, and in fact some implementations do
not use it. The result of 'Z'+1 is entirely implementation-specific.
The a more correct form of the statement would be something like, "while
in strict ASCII systems, such as some implementations of C, 'Z'+1 turns
into '[' . . ."
Brian Rodenborn
Default User Guest



Reply With Quote

