array_diff_uassoc() function uses the callback function to do index checking to calculate the difference set of the array
【Function】
This function will return an array,
This array contains all values in array1 that are not in any other parameter array.
If the first parameter is considered to be less than, equal to, or greater than the second parameter,
must be returned
An integer less than zero, equal to zero, or greater than zero
【Scope of use】
php5 (I tested this function with 5.1.6, and it is incorrect. 5.3.3 is correct, and the specific versions that work well need to be verified)
【Use】
array array_diff_uassoc( array array1, array array2[,array...,callback key_compare_func] )
array1/required/array1
array2/required/comparable array must have at least one
array.../optional/array used for comparison
key_compare_func.../Required/Provide users with a callback function as a comparison standard
【Example】
[php]
function myfunction($v1,$v2) { if ($v1===$v2) { return 0;
} if ($v1>$v2) { return 1;
} else { return -1;
} } $a1=array(0=>"Dog",1=>"Cat",2=>"Horse");
$a2=array(3=>"Dog",1=>"Cat",5=>"Horse");
print_r(array_diff_uassoc($a1,$a2,"myfunction"));
?>
Array ( [0] => Dog [2] => Horse )
Excerpted from zuodefeng’s notes