Php-Arrays function-array_diff_ukey-use the callback function to compare the difference set of the calculated array with the key name _ PHP Tutorial

Source: Internet
Author: User
Php-Arrays function-array_diff_ukey-use the callback function to compare the differences of the calculated array with the key name. The array_diff_ukey () function uses the callback function to compare the differences in the calculated array with the key name. [function] This function returns an array, this array contains all the difference sets in the array that are included in array1 but not in any other array_diff_ukey () function.

[Function]
This function returns an array,
This array contains all the key names in the array of array1 but not in any other parameter.
Note that the link remains unchanged. This comparison is performed through the callback function provided by the user.
If the first parameter is considered to be less than, equal to, or greater than the second parameter
An integer smaller than zero, equal to zero, or greater than zero
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/array for comparison
Key_compare_func.../required/provides a standard callback function
[Example]
[Php]
// Define the callback function
Function key_compare_func ($ key1, $ key2)
{
If ($ key1 = $ key2)
Return 0;
Else if ($ key1> $ key2)
Return 1;
Else
Return-1;
}
// Define two arrays respectively
$ Array1 = array ("blue" => 1, "red" => 2, "green" => 3, "purple" => 4 );
$ Array2 = array ("green" => 5, "blue" => 6, "yellow" => 7, "cyan" => 8 );
Print_r (array_diff_ukey ($ array1, $ array2, "key_compare_func "));
/*
Array
(
[Red] => 2
[Purple] => 4
)*/

Taken from zuodefeng's note

The http://www.bkjia.com/PHPjc/478202.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/478202.htmlTechArticlearray_diff_ukey () function uses the callback function to compare the difference set of the calculated array to the key name [function] This function will return an array, this array contains all but not any other...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.