David Mintz wrote:
Now I am looking atif (array_diff($one,$two) or array_diff($two,$one)) { /* do something */ } but I wonder if anyone can suggest a better way.
I can only think of a worse way by looping through one array and seeing if the key/value pair exists in the other one. That might be OK for small arrays, but my assumption is that array_diff is way more optimized. I just wonder how if() will evaluate an array. Also, when the arrays are identical the return value is an empty array. Again, I am not sure if if() evaluates and empty array differently than an array with stuff in it. Also, comments on php.net indicate that when one array in fact is not array the return value of array_diff is NULL. So, you probably need to run array_diff and then check the count of the resulting array. If it is anything else other than 0 the arrays are different. In theory, haven't tried that out.
Good luck! David K. _______________________________________________ New York PHP Community Talk Mailing List http://lists.nyphp.org/mailman/listinfo/talk NYPHPCon 2006 Presentations Online http://www.nyphpcon.com Show Your Participation in New York PHP http://www.nyphp.org/show_participation.php
