The description is kinda ambiguous at first glance, one might think that the array_diff function returns the differences across *all* given arrays (which is what I was actually looking for, and that's why I was surprised that, in the example code, the result did not include "yellow").
However, i wrote a neat oneliner to compute the differences across all given arrays:
<?php
function array_unique_values(...$arrays) {
return array_keys(array_filter(array_count_values(array_merge(...$arrays)), fn($count) => $count === 1));
}
$array1 = ['a', 'b', 'c', 'd'];
$array2 = ['a', 'b', 'x', 'y'];
$array3 = ['a', '1', 'y', 'z'];
print_r(array_unique_values($array1, $array2, $array3));
?>
Result:
Array
(
[0] => c
[1] => d
[2] => x
[3] => 1
[4] => z
)