PHP array_intersect_assoc() Function

What is array_intersect_assoc() Function?


The "array_intersect_assoc()" function is used compute the intersection of arrays with additional index check.



In the above syntax values and keys of "array1" is compared with other arrays, to return an array with the values and keys that are present in all other arrays.

Example :

$a = array (0=>'Blue',1=>'Green', 2=>'Orange', 3=>'Pink');
$b = array (0=>'Red', 1=>'Green', 3=>'Violet');
Result :

Array ( [1]=> Green )

In the above example the two arrays "$a", "$b" when compared for keys and values, returns "Green" in an array.

PHP Topics

Ask Questions

Ask Question