Home > Backend Development > PHP Tutorial > How to learn PHP array_intersect_assoc()_PHP tutorial

How to learn PHP array_intersect_assoc()_PHP tutorial

WBOY
Release: 2016-07-13 10:23:54
Original
1327 people have browsed it

How to learn PHP array_intersect_assoc()

Definition and usage

The array_intersect_assoc() function returns the intersection array of two or more arrays.

Different from the array_intersect() function, this function not only compares key values, but also compares key names. The keys of the elements in the returned array remain unchanged.

Grammar

array_intersect_assoc(array1,array2,array3...)

Parameters

Description

array1 required. The first array to compare with other arrays.

array2 required. The array to compare to the first array.

array3 is optional. The array to compare to the first array. There can be multiple.

Example 1

"Cat",1=>"Dog",2=>"Horse"); $a2=array(3=>"Horse", 1=>"Dog",0=>"Cat"); print_r(array_intersect_assoc($a1,$a2)); ?>

Output:

Array ( [0] => Cat [1] => Dog )

Example 2

"Cat",1=>"Dog",2=>"Horse"); $a2=array(3=>"Horse", 1=>"Dog",5=>"Fish"); $a3=array(6=>"Cow",1=>"Dog",8=>"Fish"); print_r(array_intersect_assoc ($a1,$a2,$a3)); ?>

Output:

Array ( [1] => Dog )

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/834962.htmlTechArticleHow to learn PHP array_intersect_assoc() Definition and usage array_intersect_assoc() function returns the intersection array of two or more arrays. Different from the array_intersect() function, this function...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template