|
Posted by Good Man on 07/25/07 14:37
Hi there
I'm trying to compare two arrays at a time to figure out if data has
changed, and array_diff_assoc is telling me that there *are differences*
between:
Array
(
[Floor Common Area] => 2878.17
[3500] => 12343.97
[3550] => 3076.52
[3570] => 1631.07
[3580] => 927.34
[3599] => 2791.54
[Storage for 3500] => 80.25
)
and:
Array
(
[3500] => 12343.97
[3550] => 3076.52
[3570] => 1631.07
[3580] => 927.34
[3599] => 2791.54
[Floor Common Area] => 2878.17
[Storage For 3500] => 80.25
)
as well as:
Array
(
[Gross Building Area] => 25306.95
[Vertical Penetrations] => 1498.76
[Floor Common Area] => 3104.52
[3600] => 13108.74
[3663] => 7429.54
[Storage for 3600] => 83.27
)
and:
Array
(
[3600] => 13108.74
[3663] => 7429.54
[Floor Common Area] => 3104.52
[Gross Building Area] => 25306.95
[Storage For 3600] => 83.27
[Vertical Penetrations] => 1498.76
)
.... obviously incorrectly. Now, it correctly reports *no differences*
between:
Array
(
[Gross Building Area] => 17128.33
[Vertical Penetrations] => 1253.81
[Building Common Area] => 15061.70
[Radio Equipment Room] => 152.21
[Spanish Broadcasting] => 231.78
)
and:
Array
(
[Building Common Area] => 15061.70
[Gross Building Area] => 17128.33
[Radio Equipment Room] => 152.21
[Spanish Broadcasting] => 231.78
[Vertical Penetrations] => 1253.81
)
I am going crazy trying to figure out why PHP tells me that the top two
array comparisons are different. This data is part of a larger set, and
my 'troublesome' comparisons seem to have one thing in common: a key
called 'Storage for xxxx', where xxxx is a number. So, i'm guessing
that one xxxx is being interpreted as a string, while the other is being
interpreted as numeric? It's possible, I guess, as all the arrays are
being created dynamically... and one is coming from a database.
Can anyone offer some insight? Do I need to write my own
array_diff_assoc function?
Btw, ksort()-ing makes no difference.
Thanks in advance....
[Back to original message]
|