PHP array_intersect_assoc() Function
Last Updated : 17 Mar 2025
The array_intersect_assoc() is used to create an array containing keys and values of the first array whose values (i.e., from the first array) are present in all other arrays, while the index of values is same for all the given arrays. This function was introduced in PHP 4.3.0.
Syntax
Parameter
| Parameter | Description | Is compulsory |
|---|---|---|
| array1 | The first array is the array that the others will be compared with. | compulsory |
| array2 | An array to be compared with the first array. | compulsory |
| array3 | An array to be compared with the first array. | Optional |
Return Type
The function returns another array that contains the intersection of all the input arrays. If no element matches, a NULL array is returned.
EXAMPLE 1
Output:
Array ( [a] => Orange )
EXAMPLE 2
Output:
Array ( [100] => sachin )
EXAMPLE 3
Output:
Array ( [a] => java [b] => php )
EXAMPLE 4
Output:
Array ( [a] => black )
Next TopicPhp-array-intersect-function