|
|
PHP array_uintersect() Function
|
Tutorials » Php »
|
Topic |
What is array_uintersect() Function?
|
|
Explanation |
|
The "array_uintersect()" function computes the intersection of arrays, compares elements by a callback function.
Syntax:
array_uintersect(array1,array2,array3...,function)
In the above syntax "array1" and "array2" are compared for values in "function" ,then returns an array of elements of "array1".
Example:
<?php
function funct1($x1,$x2)
{
if ($x1===$x2)
{
return 0;
}
if ($x1 > $x2) return 1;
{
return -1;
}
return 1;
}
}
$a=array("a"=>"Orange","b"=>"Guava","c"=>"Apple");
$b=array(1 =>"Orange",2 =>"Guava", 3 =>"Cherry");
print_r(array_uintersect($a,$b,"funct1"));
?>
Result:
Array ( [a]=> Orange [b]=> Guava );
In the above example both arrays are compared for values in "funct1", the intersecting values of "$a" is returned in an array.
|
|
A Note |
Learn PHP programming language tutorial with simple and neat example. Hope you enjoy this free tutorial.
Do give us your valuable feedback and suggestions on this online tutorial. This is a Copyright Content.
|
|
|
|