$array = [
0 => ['a' => 1, 'b' => 2, 'c' => 3],
1 => ['a' => 1, 'b' => 3, 'c' => 3],
2 => ['a' => 1, 'b' => 2, 'c' => 4],
3 => ['a' => 1, 'b' => 2, 'c' => 3],
];
$keys = array_keys($array[0]);
$keys = array_filter(
$keys,
function($key) use($array) {
count(array_unique(array_column($array, $key);)) > 1;
}
);
$array = array_map(
function($el) use($keys) {
return array_filter(
$el,
function($key) use($keys) {
return in_array($key, $keys);
},
ARRAY_FILTER_USE_KEY
);
},
$array
);
print_r($array);
/*
Array (
[0] => Array (
[b] => 2
[c] => 3
)
[1] => Array (
[b] => 3
[c] => 3
)
[2] => Array (
[b] => 2
[c] => 4
)
[3] => Array (
[b] => 2
[c] => 3
)
)
/*