Home > PHP > Function > Arrays > array_intersect()

array_intersect()

array_intersect - Computes the intersection of arrays

Syntax

array array_intersect (array $array1, array $array2, array $ ...)

Arguments

  • array1 - The array with master values to check.
  • array2 - An array to compare values against.
  • ... - A variable list of arrays to compare.

Description

array_intersect() returns an array containing all the values of array1 that are present in all the arguments. Note that keys are preserved.

Version

PHP 4.0.1, 5

Return value

Returns an array containing all of the values in array1 whose values exist in all of the parameters.