<?php $array = [ [1, 2, 3], [1, 3], [1, 2, 4, 3], [1, 3, 4] ]; $result = []; foreach ($array as $row) { $cache = [count($row), $row]; array_splice($row, 1, -1); $key = implode('-', $row); if (!isset($result[$key]) || $cache[0] < $result[$key][0]) { $result[$key] = $cache; } } var_export(array_column($result, 1));
You have javascript disabled. You will not be able to edit any code.