Copyright © tutorialspoint.com
| array array_intersect_assoc ( array $array1, array $array2 [, array $array3 ...] ); |
Returns an array containing all the values of array1 that are present in all the arguments. Note that the keys are used in the comparison unlike in array_intersect().
| Parameter | Description |
|---|---|
| array1 | Required. The first array is the array that the others will be compared with. |
| array2 | Required. An array to be compared with the first array |
| array3 | Optional. An array to be compared with the first array |
Returns an array containing all the values of array1 that are present in all the arguments.
Try out following example:
<?php
$array1 = array("a" => "green", "red", "blue");
$array2 = array("a" => "green", "yellow", "red");
$result = array_intersect_assoc($array1, $array2);
print_r($result);
?>
|
This will produce following result:
Array ( [a] => green ) |
Copyright © tutorialspoint.com