array_intersect_assoc() function in php
×


array_intersect_assoc() function in php

1648

array_intersect_assoc() function of PHP is used to create a new array by matching the keys and values of two or more associative arrays. It is an inbuilt function of PHP.

Syntax

array_intersect_assoc ($arr1,$arr2,.....$arrN);

Here,

$arr1,$arr2 and $arrN are PHP arrays.


Example:

<?php
$arr1= array("fruit1"=>"Apple","fruit2"=>"Banana","fruit3"=>"Orange","fruit4"=>"Pear");
$arr2= array("fruit1"=>"Banana","fruit2"=>"Grape","fruit3"=>"Orange","fruit4"=>"Litchi");
$result=array_intersect_assoc($arr1,$arr2);
echo "<pre>";
print_r($result);
?>

Output:




Best WordPress Hosting


Share:


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price



Leave a Reply


Comments
    Waiting for your comments