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);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KQncr
function name:  (null)
number of ops:  9
compiled vars:  !0 = $input, !1 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   ASSIGN                                                   !0, <array>
   22     1        INIT_FCALL                                               'groupbysameletters'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $3      
          4        ASSIGN                                                   !1, $3
   24     5        INIT_FCALL                                               'print_r'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Function groupbysameletters:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 23
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 23
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/KQncr
function name:  groupBySameLetters
number of ops:  31
compiled vars:  !0 = $words, !1 = $groups, !2 = $countGroups, !3 = $word, !4 = $letters, !5 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        ASSIGN                                                   !1, <array>
    6     2        ASSIGN                                                   !2, <array>
    8     3      > FE_RESET_R                                       $8      !0, ->23
          4    > > FE_FETCH_R                                               $8, !3, ->23
    9     5    >   INIT_FCALL                                               'mb_str_split'
          6        SEND_VAR                                                 !3
          7        DO_ICALL                                         $9      
          8        ASSIGN                                                   !4, $9
   10     9        INIT_FCALL                                               'sort'
         10        SEND_REF                                                 !4
         11        DO_ICALL                                                 
   11    12        INIT_FCALL                                               'implode'
         13        SEND_VAL                                                 ''
         14        SEND_VAR                                                 !4
         15        DO_ICALL                                         $12     
         16        ASSIGN                                                   !5, $12
   13    17        FETCH_DIM_W                                      $14     !1, !5
         18        ASSIGN_DIM                                               $14
         19        OP_DATA                                                  !3
   14    20        FETCH_DIM_RW                                     $16     !2, !5
         21        PRE_INC                                                  $16
    8    22      > JMP                                                      ->4
         23    >   FE_FREE                                                  $8
   17    24        INIT_FCALL                                               'array_values'
         25        SEND_VAR                                                 !1
         26        DO_ICALL                                         $18     
         27        VERIFY_RETURN_TYPE                                       $18
         28      > RETURN                                                   $18
   18    29*       VERIFY_RETURN_TYPE                                       
         30*     > RETURN                                                   null

End of function groupbysameletters

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.28 ms | 1022 KiB | 19 Q