By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,287 Members | 1,668 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,287 IT Pros & Developers. It's quick & easy.

array_diff_assoc Madness... Help?

P: n/a
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....

Jul 25 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Rik
On Wed, 25 Jul 2007 16:37:31 +0200, Good Man <he***@letsgo.comwrote:
[Storage for 3500] =80.25
[Storage For 3500] =80.25
Not the same, are they? (f vs, F)
--
Rik Wasmus
Jul 25 '07 #2

P: n/a
Rik <lu************@hotmail.comwrote in news:op.tv0ziyhxqnv3q9@metallium:
On Wed, 25 Jul 2007 16:37:31 +0200, Good Man <he***@letsgo.comwrote:
> [Storage for 3500] =80.25
[Storage For 3500] =80.25

Not the same, are they? (f vs, F)
Rik, you made my day. Thanks a bunch. Sometimes a pair of fresh eyes can
solve the most simple or complex of problems!!!!

Jul 25 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.