Re: [PHP] Array differences

2010-04-14 Thread Ashley Sheridan
On Tue, 2010-04-13 at 23:01 -0600, Ashley M. Kirchner wrote: I have the following scenario: $array1 = array(12, 34, 56, 78, 90); $array2 = array(12, 23, 56, 78, 89); $result = array_diff($array1, $array2); print_r($result); This returns:

Re: [PHP] Array differences

2010-04-14 Thread Nathan Rixham
Ashley Sheridan wrote: On Tue, 2010-04-13 at 23:01 -0600, Ashley M. Kirchner wrote: However what I really want is a two-way comparison. I want elements that don't exist in either to be returned: I don't see any problems with doing it that way. By some freak chance I made an array diff

Re: [PHP] Array differences

2010-04-14 Thread Rene Veerman
On Wed, Apr 14, 2010 at 12:03 PM, Nathan Rixham nrix...@gmail.com wrote: Ashley Sheridan wrote: On Tue, 2010-04-13 at 23:01 -0600, Ashley M. Kirchner wrote: However what I really want is a two-way comparison.  I want elements that don't exist in either to be returned: I don't see any

Re: [PHP] Array differences

2010-04-14 Thread Ashley M. Kirchner
On 4/14/2010 2:39 AM, Ashley Sheridan wrote: On Tue, 2010-04-13 at 23:01 -0600, Ashley M. Kirchner wrote: $array1 = array(12, 34, 56, 78, 90); $array2 = array(12, 23, 56, 78, 89); $diff1 = array_diff($array1, $array2); $diff2 = array_diff($array2, $array1);

Re: [PHP] Array differences

2010-04-14 Thread Ryan Sun
Maybe this one works? array_diff(array_unique($array1 + $array2), array_intersect($array1, $array2)) On Wed, Apr 14, 2010 at 4:39 AM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Tue, 2010-04-13 at 23:01 -0600, Ashley M. Kirchner wrote: I have the following scenario:      $array1 =

RE: [PHP] Array differences

2010-04-14 Thread Ashley M. Kirchner
Sun [mailto:ryansu...@gmail.com] Sent: Wednesday, April 14, 2010 8:45 AM To: a...@ashleysheridan.co.uk Cc: Ashley M. Kirchner; php-general@lists.php.net Subject: Re: [PHP] Array differences Maybe this one works? array_diff(array_unique($array1 + $array2), array_intersect($array1, $array2

Re: [PHP] Array differences

2010-04-14 Thread lala
Ashley M. Kirchner wrote: $array1 = array(1, 2, 3, 4, 5, 6); $array2 = array(1, 3, 2, 8, 9); $diff1 = array_diff($array1, $array2); $diff2 = array_diff($array2, $array1); $result = array_unique(array_merge($diff1, $diff2)); = (4, 5, 6, 8, 9)

RE: [PHP] Array differences

2010-04-14 Thread Ashley M. Kirchner
-Original Message- From: lala [mailto:l...@mail.theorb.net] Sent: Wednesday, April 14, 2010 10:15 AM To: Ashley M. Kirchner Cc: php-general@lists.php.net Subject: Re: [PHP] Array differences Ashley M. Kirchner wrote: $array1 = array(1, 2, 3, 4, 5, 6); $array2 = array

[PHP] Array differences

2010-04-13 Thread Ashley M. Kirchner
I have the following scenario: $array1 = array(12, 34, 56, 78, 90); $array2 = array(12, 23, 56, 78, 89); $result = array_diff($array1, $array2); print_r($result); This returns: Array ( [1] = 34 [4] = 90 )

Re: [PHP] Array differences

2010-04-13 Thread Rene Veerman
On Wed, Apr 14, 2010 at 7:01 AM, Ashley M. Kirchner ash...@pcraft.com wrote: I have the following scenario:     $array1 = array(12, 34, 56, 78, 90);     $array2 = array(12, 23, 56, 78, 89);     $result = array_diff($array1, $array2);     print_r($result); This returns: