3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = "hey"; function string_getpermutations($prefix, $characters, &$permutations) { if (count($characters) == 1) $permutations[] = $prefix . array_pop($characters); else { for ($i = 0; $i < count($characters); $i++) { $tmp = $characters; unset($tmp[$i]); string_getpermutations($prefix . $characters[$i], array_values($tmp), $permutations); } } } $characters = array(); for ($i = 0; $i < strlen($input); $i++) $characters[] = $input[$i]; $permutations = array(); print_r($characters); string_getpermutations("", $characters, $permutations); print_r(sort($permutations));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 4
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 4
Branch analysis from position: 11
Branch analysis from position: 4
filename:       /in/WNhBo
function name:  (null)
number of ops:  27
compiled vars:  !0 = $input, !1 = $characters, !2 = $i, !3 = $permutations
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'hey'
   19     1        ASSIGN                                                   !1, <array>
   20     2        ASSIGN                                                   !2, 0
          3      > JMP                                                      ->8
   21     4    >   FETCH_DIM_R                                      ~8      !0, !2
          5        ASSIGN_DIM                                               !1
          6        OP_DATA                                                  ~8
   20     7        PRE_INC                                                  !2
          8    >   STRLEN                                           ~10     !0
          9        IS_SMALLER                                               !2, ~10
         10      > JMPNZ                                                    ~11, ->4
   22    11    >   ASSIGN                                                   !3, <array>
   24    12        INIT_FCALL                                               'print_r'
         13        SEND_VAR                                                 !1
         14        DO_ICALL                                                 
   25    15        INIT_FCALL                                               'string_getpermutations'
         16        SEND_VAL                                                 ''
         17        SEND_VAR                                                 !1
         18        SEND_REF                                                 !3
         19        DO_FCALL                                      0          
   27    20        INIT_FCALL                                               'print_r'
         21        INIT_FCALL                                               'sort'
         22        SEND_REF                                                 !3
         23        DO_ICALL                                         $15     
         24        SEND_VAR                                                 $15
         25        DO_ICALL                                                 
         26      > RETURN                                                   1

Function string_getpermutations:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 13
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 15
Branch analysis from position: 31
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 15
Branch analysis from position: 31
Branch analysis from position: 15
filename:       /in/WNhBo
function name:  string_getpermutations
number of ops:  32
compiled vars:  !0 = $prefix, !1 = $characters, !2 = $permutations, !3 = $i, !4 = $tmp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    6     3        COUNT                                            ~5      !1
          4        IS_EQUAL                                                 ~5, 1
          5      > JMPZ                                                     ~6, ->13
    7     6    >   INIT_FCALL                                               'array_pop'
          7        SEND_REF                                                 !1
          8        DO_ICALL                                         $8      
          9        CONCAT                                           ~9      !0, $8
         10        ASSIGN_DIM                                               !2
         11        OP_DATA                                                  ~9
         12      > JMP                                                      ->31
   10    13    >   ASSIGN                                                   !3, 0
         14      > JMP                                                      ->28
   12    15    >   ASSIGN                                                   !4, !1
   13    16        UNSET_DIM                                                !4, !3
   15    17        INIT_FCALL_BY_NAME                                       'string_getpermutations'
         18        FETCH_DIM_R                                      ~12     !1, !3
         19        CONCAT                                           ~13     !0, ~12
         20        SEND_VAL_EX                                              ~13
         21        INIT_FCALL                                               'array_values'
         22        SEND_VAR                                                 !4
         23        DO_ICALL                                         $14     
         24        SEND_VAR_NO_REF_EX                                       $14
         25        SEND_VAR_EX                                              !2
         26        DO_FCALL                                      0          
   10    27        PRE_INC                                                  !3
         28    >   COUNT                                            ~17     !1
         29        IS_SMALLER                                               !3, ~17
         30      > JMPNZ                                                    ~18, ->15
   18    31    > > RETURN                                                   null

End of function string_getpermutations

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.37 ms | 1403 KiB | 22 Q