Page 1 of 1
If ('a' > 'ZZZZZ') ........guess what the answer is
Posted: Mon Oct 29, 2007 11:33 pm
by zardiw
For some reason, this is evaluating as true. I give up........lol.........z
Code: Select all
If ('a' > 'ZZZZZ') {
Print("a is more than zzzzzs");
?><BR><?;
}
a is more than zzzzzs
Posted: Tue Oct 30, 2007 2:22 am
by s.dot
That's some interesting behavior.
Code: Select all
C:\Users\scott>php -r "var_dump($a = 'a' > 'ZZZZ');"
bool(true)
C:\Users\scott>php -r "var_dump($a = 'a' > 'z');"
bool(false)
C:\Users\scott>php -r "var_dump($a = 'a' > 'Z');"
bool(true)
Seems it's the case that matters.
I imagine a-z is in order of ranking as suspected, where as A ranks slightly below z, and follows from A-Z in the same manner.
Posted: Tue Oct 30, 2007 2:32 am
by Benjamin
Z is lower than a in ascii, and if it's comparing it as a string, a would be greater than Z.
Posted: Tue Oct 30, 2007 2:40 am
by s.dot
Code: Select all
C:\Users\scott>php -r "$r1 = range('a', 'z'); $r1 = array_merge($r1, $r1); $r2 =
array_merge(range('a', 'z'), range('A', 'Z')); $i=1; foreach ($r1 AS $r) { echo
$r > $r2[$i] ? $r . ' is greater than ' . $r2[$i] : $r . ' is less than ' . $r2
[$i]; $i++; }"
a is less than b
b is less than c
c is less than d
d is less than e
e is less than f
f is less than g
g is less than h
h is less than i
i is less than j
j is less than k
k is less than l
l is less than m
m is less than n
n is less than o
o is less than p
p is less than q
q is less than r
r is less than s
s is less than t
t is less than u
u is less than v
v is less than w
w is less than x
x is less than y
y is less than z
z is greater than A
a is greater than B
b is greater than C
c is greater than D
d is greater than E
e is greater than F
f is greater than G
g is greater than H
h is greater than I
i is greater than J
j is greater than K
k is greater than L
l is greater than M
m is greater than N
n is greater than O
o is greater than P
p is greater than Q
q is greater than R
r is greater than S
s is greater than T
t is greater than U
u is greater than V
v is greater than W
w is greater than X
x is greater than Y
y is greater than Z

Posted: Tue Oct 30, 2007 9:50 am
by zardiw
I was running a while statement. I have a MySql database with the primary key being a stock symbol. The keys are both lower and upper case, so apparently I have to make them all one or the other.........Thanks for the info guys..............z
Posted: Wed Oct 31, 2007 7:54 pm
by califdon
It's called collation sequence. There are different sequences for different languages and even several for the english alphabet. Some databases let you specify the collation sequence for each table, or when you are sorting data. cf:
http://en.wikipedia.org/wiki/Collating_sequence and Google it.
Posted: Wed Oct 31, 2007 9:36 pm
by zardiw
MySql doesn't care if it's upper or lower case. Some of the keys are part upper and lower.
Somebody said I should use strcasecmp(), but I think I'll just pass the DB and change everything to upper case, and then use strtoupper() when I'm adding new records.......z
Posted: Wed Oct 31, 2007 9:41 pm
by zardiw
astions wrote:Z is lower than a in ascii, and if it's comparing it as a string, a would be greater than Z.
The actual compare was
Code: Select all
while $CurrSymb < 'ZZZZZ' {
do a bunch of crap
}
z
Posted: Wed Oct 31, 2007 10:09 pm
by Benjamin
I'm aware of that. You have most likely implemented your own, albeit more resource intensive, version of MySQL's built in COALESCE function.
Refer to:
http://dev.mysql.com/doc/refman/5.0/en/ ... n_coalesce
Posted: Wed Oct 31, 2007 10:25 pm
by zardiw
Well I have little control of the implementation on my webhost's server........is there something I can set to use a less resource intensive process?...........z
Posted: Wed Oct 31, 2007 10:54 pm
by Benjamin
What are you trying to accomplish?