<?php $array = [[6],[6],[6],[5,1],[3,3],[3,3],[3,2,1],[3,1,2],[2,1,3]]; $result = []; foreach ($array as $row) { sort($row); $key = json_encode($row); $result[$key] = [$row, ($result[$key][1] ?? 0) + 1]; } echo json_encode(array_values($result));
You have javascript disabled. You will not be able to edit any code.