Home > php教程 > php手册 > array_intersect_key:根据键名计算数组的交集

array_intersect_key:根据键名计算数组的交集

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 19:39:44
Original
1516 people have browsed it

arrayarray_intersect_key(array$array1,array$array2[,array$...]) 返回一个数组:该数组的键在每一个数组都存在 $arr1 = ['a'='abc','b'='bbb','c'='cbd'];$arr2 = ['a'='ccc','c'='aaa','e'='eee'];$arr = array_intersect_key($arr1, $arr2);echo 'pre';p

array array_intersect_key ( array $array1 , array $array2 [, array $ ... ] )
返回一个数组:该数组的键在每一个数组都存在

$arr1 = ['a'=>'abc','b'=>'bbb','c'=>'cbd'];
$arr2 = ['a'=>'ccc','c'=>'aaa','e'=>'eee'];
$arr = array_intersect_key($arr1, $arr2);

echo '<pre class="brush:php;toolbar:false">';
print_r($arr);

result:
Array
(
    [a] => abc
    [c] => cbd
)
Copy after login

Related labels:
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
Latest Issues
How to create an array within an array?
From 1970-01-01 08:00:00
0
0
0
php array
From 1970-01-01 08:00:00
0
0
0
Array to array
From 1970-01-01 08:00:00
0
0
0
php array rotation
From 1970-01-01 08:00:00
0
0
0
array
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template