Home >> PHP >> array_uintersect_assoc() function in PHP

array_uintersect_assoc() function in PHP

The array_uintersect_assoc() function used for compares the keys and values by user defined function of two or more arrays, and returns the common elements.

Syntax

array_uintersect_assoc(array1,array2,array3...,yourfunction);

Example

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

$array1 = array("a"=>"red","b"=>"green","c"=>"blue","d"=>"yellow");
$array2 = array("a"=>"red","b"=>"green","c"=>"blue");

print_r(array_uintersect_assoc($array1,$array2,"yourfunction"));

Output

Array ( [a] => red [b] => green [c] => blue )

Post Your Comment

Next Questions
array_uintersect_uassoc() function
array_unique() function
array_unshift() function
array_values() function
array_walk() function
array_walk_recursive() function
asort() function
arsort() function
compact() function
count() function
current() function
each() function
end() function
extract() function
in_array() function
key() function
krsort() function
ksort() function
list() function
natcasesort() function
natsort() function
pos() function
prev() function
range() function
reset() function

Copyright ©2022 coderraj.com. All Rights Reserved.