← All built-ins / array_intersect()

array_intersect()

array_intersect(...$args): mixed

Parameters

NameTypeDescription
$...arrayfirst the base array, then arrays to intersect with

Return value

Values of the first array that appear in all the others.

Example

echo implode(",", array_intersect([1, 2, 3, 4], [2, 4, 5]));
2,4

See also

array_diff()in_array()