Home >> PHP >> array_udiff_uassoc() function in PHP

array_udiff_uassoc() function in PHP

The array_udiff_uassoc() function compares the keys and values by two user defined function of two or more arrays, and returns the differences.

Syntax

array_udiff_uassoc(array1,array2,array3...,yourfunction_key,yourfunction_value);

Example

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

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

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

print_r(array_udiff_uassoc($array1,$array2,"yourfunction_key","yourfunction_value"));

Output

Array ( [c] => blue )

Post Your Comment

Next Questions
array_uintersect() function
array_uintersect_assoc() function
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

Copyright ©2022 coderraj.com. All Rights Reserved.