English[ˌɪntəˈsekt] US[ˌɪntərˈsekt]
##vt. Cross, cut across, cross vt.& vi. (referring to lines, roads, etc.) intersect, cross Third person singular: intersects Present participle: intersecting Past tense: intersected Past participle: intersectedphp array_intersect() function syntax
Function:Used to compare the key values of two (or more) arrays and return the intersection.
Syntax:array_intersect(array1,array2,array3...)
Parameters:
Parameters | Description |
array1 | Required. The first array to compare with other arrays. |
array2 | Required. The array to compare to the first array. |
array3,... | Optional. Additional array to compare with the first array. |
Note:The result array contains all the values in the compared array and also in all other parameter arrays. The key names are not retained. Change.
php array_intersect() function example
"降龙十八掌","黄蓉"=>"打狗棍法","西门"=>"吹雪剑法","过儿"=>"黯然销魂掌"); $a2=array("黄蓉"=>"打狗棍法","小龙女"=>"玉女心经","金轮法王"=>"龙象般若功"); $a3=array("裘千仞"=>"九阴白骨爪","天山童姥"=>"天山传音","黄蓉"=>"打狗棍法"); $result=array_intersect($a1,$a2,$a3); //返回三个数组中都存在的元素 print_r($result); ?>
Run instance»
Click the "Run instance" button to view the online instance
Output:
Array ( [黄蓉] => 打狗棍法 )