array_intersect
计算数组的交集
&reftitle.description;
arrayarray_intersect
arrayarray
arrayarrays
array_intersect 返回一个数组,该数组包含了所有在
array 和其它参数数组中同时存在的值。注意,键名保留不变。
&reftitle.parameters;
array
要检查的数组,作为主值。
arrays
要被对比的数组。
&reftitle.returnvalues;
返回一个数组,该数组包含了所有在
array 和其它参数数组中同时存在的值。
&reftitle.changelog;
&Version;
&Description;
&array.changelog.require-only-one;
&reftitle.examples;
array_intersect 例子
"green", "red", "blue");
$array2 = array("b" => "green", "yellow", "red");
$result = array_intersect($array1, $array2);
print_r($result);
?>
]]>
&example.outputs;
green
[0] => red
)
]]>
&reftitle.notes;
两个单元仅在 (string) $elem1 === (string) $elem2
时被认为是相同的。也就是说:当字符串的表达形式相同时。
&reftitle.seealso;
array_intersect_assoc
array_diff
array_diff_assoc