Example 1 — Common Values, Ignoring Case
Find fruit names that appear in both lists, whatever the capitalization.
<?php
$a = ["Apple", "Banana", "Cherry"];
$b = ["banana", "cherry", "date"];
$common = array_uintersect($a, $b, fn($x, $y) => strcasecmp($x, $y));
echo implode(", ", $common), PHP_EOL; How It Works
- The two lists use different capitalization.
- strcasecmp() treats "Banana" and "banana" as equal.
- "Apple" is not in the second list, and "date" is not in the first.
- The result uses the spelling from the first array: Banana and Cherry.

