array_uintersect_uassoc()
array_uintersect_uassoc() — Computes the intersection of arrays with additional index check, compares data and indexes by separate callback functions.
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_uintersect_uassoc(array $array1, array ...$arrays, callable $value_compare_func, callable $key_compare_func): array callback(mixed $a, mixed $b): int
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $array1 | array | The first array. |
| ...$arrays | array | Further arrays. |
| $value_compare_func | callable | The sorting callback must handle any value from any array in any order, regardless of the order they were originally provided. This is because each individual array is first sorted before being compared against other arrays. For example: <?php $arrayA = ["string", 1]; $arrayB = [["value" => 1]]; // $item1 and $item2 can be any of "string", 1 or ["value" => 1] $compareFunc = static function ($item1, $item2) { $value1 ... |
| $key_compare_func | callable | Key comparison callback function. |
Return value
Returns an array containing all the values of array1 that are present in all the arguments.
Example
A runnable snippet:
$array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red"); $array2 = array("a" => "GREEN", "B" => "brown", "yellow", "red"); print_r(array_uintersect_uassoc($array1, $array2, "strcasecmp", "strcasecmp"));
Output:
Array ( [a] => green [b] => brown )
See also
array_uintersect(), array_intersect_assoc(), array_intersect_uassoc(), array_uintersect_assoc()
All PHP 8.5 built-in functions
Reference card built from the PHP manual page array_uintersect_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.