Example 1 — Ignore Case Everywhere
Match entries whose keys and values are equal ignoring case.
<?php
$a = ["A" => "red", "B" => "green"];
$b = ["a" => "RED", "b" => "blue"];
$common = array_uintersect_uassoc(
$a,
$b,
fn($x, $y) => strcasecmp($x, $y),
fn($x, $y) => strcasecmp($x, $y)
);
echo json_encode($common), PHP_EOL; How It Works
- The first callback compares values and the second compares keys.
- Key "A" matches "a" and "red" matches "RED", so this entry is kept.
- Key "B" matches "b", but "green" is not "blue", so it is dropped.
- The result uses the key and value from the first array.

