Example 1 — Case Insensitive Key Comparison
Pass strcasecmp as the callback so that 'a' and 'A' count as the same key.
<?php
$a = ['a' => 'green', 'b' => 'brown', 'c' => 'blue', 'red'];
$b = ['A' => 'green', 'yellow', 'red'];
print_r(array_diff_uassoc($a, $b, 'strcasecmp')); How It Works
- strcasecmp treats the keys 'a' and 'A' as equal.
- 'a' => 'green' therefore matches 'A' => 'green' and is removed.
- The keys 'b' and 'c' have no match in $b, so they are kept.
- 'red' at key 0 is kept because key 0 in $b holds 'yellow'.

