3v4l.org

run code in 300+ PHP versions simultaneously
<?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));

preferences:
178.24 ms | 407 KiB | 5 Q