I think you're trying to defy logic here. How will the function know that
you want to keep color=>cherry or flavor=>cherry? What logical construct
makes that decision? The example you've given will result in an array that
looks eactly like $arr1 regardless of the content in either array.
$arr1 = array("color" => "red", "flavor" => "cherry");
$arr2 = array("color" => "cherry", "flavor" => "red");
print_r(myArrayDiff($arr1, $arr2));
-Kevin
----- Original Message -----
From: "Nick Eby" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, November 08, 2002 4:15 PM
Subject: [PHP] Re: wanted: array_diff for more than values
> in case anyone cares, here is my solution so far, please comment if you
feel
> the need.
>
> function myArrayDiff($thing1, $thing2)
> {
> $diff = array();
> while (list($key, $val) = each($thing1))
> {
> if ((string)$val !== (string)$thing2[$key])
> $diff[$key] = $val;
> }
>
> return $diff;
> }
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php