- array_values: documentation ( source)
- sort: documentation ( source)
- json_encode: documentation ( source)
<?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));