PHP---ARRAY_INTERSECT_ASSOC

Source: Internet
Author: User

Array_intersect_assoc

(PHP 4 >= 4.3.0, PHP 5, PHP 7)

array_intersect_assoc-with index Check the intersection of computed arrays

Description

Array Array_intersect_assoc (array $array 1, array $array 2 [, array $ ...])

ARRAY_INTERSECT_ASSOC () returns an array that contains all the values in Array1 that also appear in all other parameter arrays. Note that unlike Array_intersect (), the key name is also used for comparison.

Parameters

Array1

The primary value to check.

Array2

The array to compare.

...

The list of array variables to compare.

return value

Returns an array that contains all the values in Array1 that also appear in all other parameter arrays.

Example

Example #1 Array_intersect_assoc () example

<?php
$array 1 = Array ("A" = "green", "b" = "Brown", "c" = "blue", "Red");
$array 2 = Array ("A" = "green", "b" = "yellow", "blue", "Red");
$result _array = Array_intersect_assoc ($array 1, $array 2);
Print_r ($result _array);
?>

The above routines will output:

Array

(

[A] = Green

)

As you can see in the above example, only the key value pairs "a" and "green" are present in two arrays and are returned. The value "Red" is not returned because in $array 1 Its key name is 0 and in $array 2 The key name of "Red" is 1, the key " B " is not returned because its value differs from other arrays.

The key value pair key = Two values in value are considered equal only when (string) $elem 1 = = = (string) $elem 2 . This means that strict checks are used, and the expression of the strings must be the same.

See

PHP---ARRAY_INTERSECT_ASSOC

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.