array_diff_uassoc()

array_diff_uassoc() — Computes the difference of arrays with additional index check which is performed by a user supplied callback function.

Built-in function of PHP 8.5. The manual lists it as available in PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

Signature

array_diff_uassoc(array $array, array ...$arrays, callable $key_compare_func): array callback(mixed $a, mixed $b): int

Parameters

ParameterTypeWhat it takes
$arrayarrayThe array to compare from
...$arraysarrayArrays to compare against
$key_compare_funccallableThe comparison function must 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

Returns an array containing all the entries from array that are not present in any of the other arrays.

Example

A runnable snippet:

function key_compare_func($a, $b) { return $a <=> $b; } $array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red"); $array2 = array("a" => "green", "yellow", "red"); $result = array_diff_uassoc($array1, $array2, "key_compare_func"); print_r($result);

Output:

Array ( [b] => brown [c] => blue [0] => red )

See also

array_diff(), array_diff_assoc(), array_udiff(), array_udiff_assoc(), array_udiff_uassoc(), array_intersect(), array_intersect_assoc(), array_uintersect(), array_uintersect_assoc(), array_uintersect_uassoc()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page array_diff_uassoc() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.