Source Code:
(back to article)
<?php $input = [[1, 2, 3], [2, 3, 4], [3, 4, 5]]; // Convert the multi-dimensional array into a single-dimensional array $single_dimensional_array = array_merge(...$input); // Remove the duplicate values from the single-dimensional array $single_dimensional_array = array_unique($single_dimensional_array); // Convert the single-dimensional array back into a multi-dimensional array $result = array_chunk($single_dimensional_array, count($input[0])); print_r($result);
Result:
Report an issue