3v4l.org

run code in 500+ PHP versions simultaneously
<?php $a = [ 'admin' => [ 'user', 'changeUser', ], 'user' => [ 'guest', 'updatePassword', ], 'guest' => [ 'login', 'admin', ], ]; $role = 'admin'; $permissions = $a[$role]; $groups = []; $final = []; while (!empty($permissions)) { $permission = array_shift($permissions); if (in_array($permission, $groups)) { continue; } if (!empty($a[$permission])) { array_push($groups, $permission); array_push($permissions, ...$a[$permission]); } else { $final[] = $permission; } } var_export($final);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 7
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 14
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 28
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 7
Branch analysis from position: 33
Branch analysis from position: 7
filename:       /in/66Bb8
function name:  (null)
number of ops:  37
compiled vars:  !0 = $a, !1 = $role, !2 = $permissions, !3 = $groups, !4 = $final, !5 = $permission
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   18     1        ASSIGN                                                       !1, 'admin'
   20     2        FETCH_DIM_R                                          ~8      !0, !1
          3        ASSIGN                                                       !2, ~8
   21     4        ASSIGN                                                       !3, <array>
   22     5        ASSIGN                                                       !4, <array>
   24     6      > JMP                                                          ->30
   25     7    >   INIT_FCALL                                                   'array_shift'
          8        SEND_REF                                                     !2
          9        DO_ICALL                                             $12     
         10        ASSIGN                                                       !5, $12
   27    11        FRAMELESS_ICALL_2                in_array            ~14     !5, !3
         12      > JMPZ                                                         ~14, ->14
   28    13    > > JMP                                                          ->30
   31    14    >   ISSET_ISEMPTY_DIM_OBJ                             1  ~15     !0, !5
         15        BOOL_NOT                                             ~16     ~15
         16      > JMPZ                                                         ~16, ->28
   32    17    >   INIT_FCALL                                                   'array_push'
         18        SEND_REF                                                     !3
         19        SEND_VAR                                                     !5
         20        DO_ICALL                                                     
   33    21        INIT_FCALL                                                   'array_push'
         22        SEND_REF                                                     !2
         23        FETCH_DIM_R                                          ~18     !0, !5
         24        SEND_UNPACK                                                  ~18
         25        CHECK_UNDEF_ARGS                                             
         26        DO_ICALL                                                     
   31    27      > JMP                                                          ->30
   35    28    >   ASSIGN_DIM                                                   !4
         29        OP_DATA                                                      !5
   24    30    >   ISSET_ISEMPTY_CV                                     ~21     !2
         31        BOOL_NOT                                             ~22     ~21
         32      > JMPNZ                                                        ~22, ->7
   39    33    >   INIT_FCALL                                                   'var_export'
         34        SEND_VAR                                                     !4
         35        DO_ICALL                                                     
         36      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
161.69 ms | 1401 KiB | 16 Q