"Kevin Stone" <[EMAIL PROTECTED]> wrote:
> 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 r
yes, i'm aware of that. what i'm asking is, is there a PHP function (or a
one-liner composite of several functions?) that can do an array_diff while
also checking the key=>value mapping.
"Baroiller Pierre-Emmanuel" <[EMAIL PROTECTED]> wrote in message
news:20021109001822.33085.qmail@;pb1.pair.co
array_diff check value, not keys..
"Nick Eby" <[EMAIL PROTECTED]> a écrit dans le message de news:
[EMAIL PROTECTED]
> example:
> $arr1 = array("color" => "red", "flavor" => "cherry");
> $arr2 = array("color" => "cherry", "flavor" => "red");
> print_r(array_diff($arr1, $arr2));
>
> those 2 arrays
t;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 myArra
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 Genera
5 matches
Mail list logo