The Array_diff_ukey () function uses a callback function to compare the difference set of an array to a key name
function
The function will return an array,
The array contains all the values in array1 but not the key names in any of the other parameter arrays.
Note that the association relationship remains the same. This comparison is done through a user-supplied callback function.
If you think that the first parameter is less than, equal to, or greater than the second argument, you must return a
An integer less than 0, equal to zero, or greater than 0
"Scope of Use"
PHP5 > 5.1.0
Use
Array Array_diff_ukey (array array1, array array2[,array...,callback Key_compare_func])
array1/Required/Array 1
array2/required/Compared arrays must have at least one
Array.../Optional/used to compare the array
Key_compare_func.../Required/provides the user with a callback function as a standard for comparison
Example
[PHP]
Defining callback Functions
function Key_compare_func ($key 1, $key 2)
{
if ($key 1 = = $key 2)
return 0;
else if ($key 1 > $key 2)
return 1;
Else
return-1;
}
Define two arrays separately
$array 1 = Array ("Blue" = 1, "Red" = 2, "green" = 3, "purple" = 4);
$array 2 = Array ("green" = 5, "Blue" = 6, "Yellow" = 7, "cyan" = 8);
Print_r (Array_diff_ukey ($array 1, $array 2, "Key_compare_func"));
/*
Array
(
[Red] = 2
[Purple] = 4
)*/
Excerpts from Zuodefeng's notes
http://www.bkjia.com/PHPjc/478202.html www.bkjia.com true http://www.bkjia.com/PHPjc/478202.html techarticle The Array_diff_ukey () function uses a callback function to compare the difference set of an array with a key name "function" The function returns an array that contains all the array1 but not any other ...