I wrote this function to recursively replace array keys with array values (flip) and fill values with defined value. it can be used for recursive array intersect functions .
<?php
function array_values_to_keys_r($array, $fill_value = null)
{
$flipped = [];
foreach ($array as $key => $value) {
if (is_array($value)) {
$flipped [$key] = array_values_to_keys_r($value);
} else {
$flipped [$value] = $fill_value;
}
}
return $flipped;
}
?>