Array Intersect Assoc Function in PHP

In this article I explain array_intersect_assoc function in PHP.
  • 1795

PHP array_intersect_assoc Function

The array_intersect_assoc function computes the intersection of an array with additional checks and returns an array with the key and value from the first array but the values and keys are present in all of the other array.

Syntax

array_intersect_assoc(array1, array2,................)

Parameter

The parameters for the array_intersect_assoc function are:

Parameter Description
array1 It specifies an array, who is compare from others.
array2 It specifies an array to compare against first array.
................ It specifies more array to compare against first array.

Example

An example of the array_intersect_assoc function is:

<?php
echo
"<pre>";
$
val = array(1 => "Apple", 2 => "Mango", 3 => "Orange", "Banana");
$val2 = array(1 => "Apple", 2=>"Raspberry", "banana");
$interscet = array_intersect_assoc($val,$val2);
print_r($interscet);

?>


Output

array-intersect-assoc-function-in-php.jpg

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.