PHP array_uintersect () and array_uintersect_assoc () Tutorial

Source: Internet
Author: User

PHP array_uintersect () and array_uintersect_assoc () instance tutorial

Definition and usage
The array_uintersect () function compares two or more arrays in the user's function and returns an array containing content from the first array if the user's function permits it. The user's function compares the array value and returns a value. If the returned value is 0, the array should contain this content.

Syntax
Array_uintersect (array1, array2, array3., function)
Parameter description: required by array1. The first array, the other will be required with array2. An array is optional relative to the first array array3. An array is a functional requirement relative to the first array. Note: You can compare the first array with an array, or you like it. Note: Only value is used for comparison. For example, <? Php
Function myfunction ($ v1, $ v2)
{
If ($ v1 ===$ v2)
{
Return 0;
}
If ($ v1> $ v2) return 1;
{
Return-1;
}
Return 1;
}
$ A1 = array ("a" => "Cat", "B" => "Dog", "c" => "Horse ");
$ A2 = array (1 => "Cat", 2 => "Dog", 3 => "Fish ");
Print_r (array_uintersect ($ a1, $ a2, "myfunction "));
?> Output result. array ([a] => Cat [B] => Dog) to see the array_uintersect_assoc () instance tutorial definition and usage. The array_uintesect_assoc () function compares two or more arrays, whether it is in built-in functions and in user functions, then return an array containing content from the first array if it permits its functions. The built-in functions are the key. The user's function compares the value and returns a value. If the returned value is 0, the array should contain this content. The array_uintersect_assoc (array1, array2, array3. .., function) parameter describes the requirements of array1. The first array, the other will be required with array2. An array is optional relative to the first array array3. An array is a functional requirement relative to the first array. Note: You can compare the first array with an array, or you like it. Note: For comparison, the key is to use the built-in functions and values for user functions. For example, <? Php
Function myfunction ($ v1, $ v2)
{
If ($ v1 ===$ v2)
{
Return 0;
}
Return 1;
}
$ A1 = array ("a" => "Cat", "B" => "Dog", "c" => "Horse ");
$ A2 = array ("a" => "Cat", "B" => "Horse", "c" => "Dog ");
Print_r (array_uintersect_assoc ($ a1, $ a2, "myfunction "));
?> Output result. Array ([a] Cat)

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.