PHP array_uintersect_assoc() Function

What is array_uintersect_assoc() Function?

Explanation

The "array_uintersect_assoc()" function computes the intersection of arrays with additional index check, compares data by a callback function.

Syntax:


array_uintersect_assoc(array1,array2,array3...,function)

In the above syntax "array1" and "array2" are compared in the user defined function for values, and for keys in the built in function ,then returns an array of elements from "array1".

Example :


<?php
function funct1($x1,$x2)
{
if ($x1===$x2)
{
return 0;
}
return 1;
}
$a=array("a"=>"Orange","b"=>"Apple","c"=>"Guava");
$b=array("a"=>"Orange","b"=>"Guava","c"=>"Apple");
print_r(array_uintersect_assoc($a,$b,"funct1"));
?>
Result :

Array ( [a]=> Orange );

In the above example the values, keys of both arrays are compared to find the intersection of array elements, which is returned in an array.

PHP Topics


Ask Questions

Ask Question