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);

      $result = array_unique(array_merge($diff1, $diff2));

      print_r($result);

I don't see any problems with doing it that way. This will only work as you intended if both arrays have the same number of elements I believe, otherwise you might end up with a situation where your final array has duplicates of the same number:

$array1 = $array(1, 2, 3, 4, 5, 6);
$array2 = $aray(1, 3, 2, 5);

Wouldn't array_unique() take care of that though? Your example above returns 4 and 6, which would be correct.

    A

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to