3v4l.org

run code in 300+ PHP versions simultaneously
<?php function groupBySameLetters(array $words): array { $groups = []; $countGroups[]; foreach ($words as $word) { $letters = mb_str_split($word); sort($letters); $key = implode('', $letters); $groups[$key][] = $word; $countGroups[$key] ++; } return array_values($groups); } // Приклад використання: $input = ['ab', 'ac', 'ba', 'ca']; $result = groupBySameLetters($input); print_r($result);
Output for 8.5.0 - 8.5.1
Fatal error: Cannot use [] for reading in /in/MKeET on line 6 Stack trace: #0 {main}
Process exited with code 255.
Output for 8.1.34, 8.2.27 - 8.2.30, 8.3.0 - 8.3.29, 8.4.1 - 8.4.16
Fatal error: Cannot use [] for reading in /in/MKeET on line 6
Process exited with code 255.

preferences:
133.87 ms | 1010 KiB | 7 Q