Php-Arrays function-array_diff_uassoc-use the callback function for index check to calculate the difference value of the array _ PHP Tutorial

Source: Internet
Author: User
Php-Arrays function-array_diff_uassoc-uses the callback function for index check to calculate the array difference. The array_diff_uassoc () function uses the callback function to perform an index check to calculate the array's difference set. [function] This function returns an array containing all the array1 but not all other array_diff_uassoc () the function performs an index check using the callback function to calculate the difference set of the array.

[Function]
This function returns an array,
This array contains all values in the array of array1 but not in any other parameter.
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 (I tested this function with 5.1.6, which is incorrect. 5.3.3 is correct, and which versions are available for verification)
[Use]
Array array_diff_uassoc (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]
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)


Taken from zuodefeng's note

The http://www.bkjia.com/PHPjc/478201.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/478201.htmlTechArticlearray_diff_uassoc () function uses the callback function for index check to calculate the array's difference set [function] This function will return an array that contains all the values in array1 but not in 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.