array_uintersect_assoc()
array_uintersect_assoc() — Computes the intersection of arrays with additional index check, compares data by a 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_uintersect_assoc(array $array, array ...$arrays, callable $value_compare_func): array callback(mixed $a, mixed $b): int
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $array | array | The first array. |
| ...$arrays | array | Arrays to compare against. |
| $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 ... |
Return value
Returns an array containing all the values of array 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_assoc($array1, $array2, "strcasecmp"));
Output:
Array ( [a] => green )
See also
array_uintersect(), array_intersect_assoc(), array_intersect_uassoc(), array_uintersect_uassoc()
All PHP 8.5 built-in functions
Reference card built from the PHP manual page array_uintersect_assoc() (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.