English[??nt??sekt] US[??nt?r?sekt]
##vt. Cross, cut across, cross vt.& vi. (referring to lines, roads, etc.) intersect, crossThird person singular: intersects Present participle: intersecting Past tense: intersected Past participle: intersected
php 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
<?php $a1=array("郭靖"=>"降龍十八掌","黃蓉"=>"打狗棍法","西門"=>"吹雪劍法","過兒"=>"黯然銷魂掌"); $a2=array("黃蓉"=>"打狗棍法","小龍女"=>"玉女心經(jīng)","金輪法王"=>"龍象般若功"); $a3=array("裘千仞"=>"九陰白骨爪","天山童姥"=>"天山傳音","黃蓉"=>"打狗棍法"); $result=array_intersect($a1,$a2,$a3); //返回三個數(shù)組中都存在的元素 print_r($result); ?>
Run instance?
Click the "Run instance" button to view the online instance
Output:
Array ( [黃蓉] => 打狗棍法 )