Definition :
The array_intersect_assoc()
function compares the elements of two or more arrays and returns the matches. Unlike array_intersect()
, the array keys are also used in the comparison.
This function compares the keys and values of two or more arrays, and return an array that contains the entries from array1 that are present in array2, array3, etc.
array_intersect_assoc(array1,array2,array3, ...)
The array_intersect_assoc()
function accepts the following parameters.
Parameter | Description |
---|---|
array1 | Required. Specifies the array to compare from. |
array2 | Required. Specifies an array to compare against. |
array3 | Optional. Specifies more arrays to compare against. |
The following example shows the array_intersect_assoc()
function in action.
Example :
Output :
Array
(
[a] => Web
)
Another Example :
In the following example this function compares an array against two other arrays.
Output :
Array
(
[a] => Web
[b] => designing
)