NYCPHP Meetup

[nycphp-talk] array_diff that works both ways ?

David Mintz dmintz at panix.com
Sat Aug 2 15:34:51 EDT 2003


On Sat, 2 Aug 2003, Jon Baer wrote:

> dont think u need to sort, u could just merge results:
>
> $array1 = array(1,2,3);
> $array2 = array(2,3,4);
> $array3 = array_merge(array_diff($array1, $array2), array_diff($array2,
> $array1));
> print_r($array3);
>
> but i think u r right there should be a "array_diff_recursive" method or
> something.

that makes sense. I ended up doing this, because all i really need is a
boolean

function isDifferent($array1,$array2) {
    return sizeof(array_diff($array1,$array2)) +
        sizeof(array_diff($array2,$array1)) > 0 ;
}

and I guess that's sane... Sane Enough, to coin a phrase

thanks!


---
David Mintz
http://davidmintz.org/
Email: See http://dmintzweb.com/whitelist.php first!

Decibels of sound pressure employed by a new "thermoacoustic" refrigerator: 190
Decibels of sound pressure sufficient to ignite a person's hair: 165

	-- Harper's Index, February 2003



More information about the talk mailing list