Example 1 — Match Keys Ignoring Case
Use strcasecmp so that Apple and apple are treated as the same key.
<?php
$a = ["Apple" => 1, "Banana" => 2, "Cherry" => 3];
$b = ["apple" => 9, "cherry" => 8];
$result = array_intersect_ukey($a, $b, "strcasecmp");
echo json_encode($result), PHP_EOL; How It Works
- Build two arrays. The second one uses lowercase keys.
- Pass strcasecmp. It makes
Appleequal toapple. - Values are ignored. It does not matter that
1and9differ. - Read the result. The original keys and values of
$aare returned.

