From http://www.w3schools.com (Copyright Refsnes Data)
The array_uintersect_uassoc() function compares two or more arrays, in two user-made functions, and returns an array containing the elements from the first array, if the user-made functions allow it. The first user-made function compares array keys, and the second compares array values, and both returns a numeric value, 0 if the returned array should contain this element.
array_uintersect_uassoc(array1,array2,array3...,function1,function2) |
Parameter | Description |
---|---|
array1 | Required. The first array is the array that the others will be compared with |
array2 | Required. An array to be compared with the first array |
array3 | Optional. An array to be compared with the first array |
function1 | Required. The name of the user-made function that compares the array keys |
function2 | Required. The name of the user-made function that compares the array values |
Tip: You can compare the first array with one array, or as many as you like.
Note: For comparison, the key is used in the first function and the value is used in the second. They are both user-made functions.
<?php function myfunction_key($v1,$v2) { if ($v1===$v2) { return 0; } return 1; } function myfunction_value($v1,$v2) { if ($v1===$v2) { return 0; } return 1; } $a1=array("a"=>"Cat","b"=>"Dog","c"=>"Horse"); $a2=array("a"=>"Cat","b"=>"Dog","c"=>"Dog"); print_r(array_uintersect_uassoc($a1,$a2,"myfunction_key","myfunction_value")); ?> |
The output of the code above will be:
Array ( [a] => Cat [b] => Dog ) |
From http://www.w3schools.com (Copyright Refsnes Data)