PHP array_uintersect_assoc function

Last Updated: February 15, 2022

array_uintersect_assoc : Computes the intersection of arrays with comparing index and value. A callback function is used

Syntax

array_uintersect_assoc(array $array, array ...$arrays, callable $value_compare_func): array

Parameters

Parameter Description
array Required. array with values to check intersected values
arrays Required. arrays to be compared with the first array
value_compare_func

callback function for values

return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second.

Return Value

Return an array containing elements that are also appearing in other arrays

Example

function myValue_function($a,$b)
{
    if ($a===$b)
    {
        return 0;
    }
    return ($a>$b)?1:-1;
}

$a1=array("a"=>"one","b"=>"two","c"=>"three");
$a2=array("a"=>"one","b"=>"three","c"=>"four");

$result=array_uintersect_assoc($a1,$a2,"myValue_function");
print_r($result);

Output

Array ( [a] => one ) 
Test