3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = 'ABC1'; permute(str_split($str), 0, strlen($str)); function permute($arr, $i, $n) { if ($i == $n) { printArray($arr); return; } for ($j = $i; $j < $n; $j += 1) { swapArrayValues($arr, $i, $j); permute($arr, $i + 1, $n); swapArrayValues($arr, $i, $j); } } function swapArrayValues(&$array, $i, $j) { $tmp = $array[$i]; $array[$i] = $array[$j]; $array[$j] = $tmp; } function printArray($arr) { echo implode($arr, ' ') . "\n"; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DSo4D
function name:  (null)
number of ops:  11
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, 'ABC1'
    6     1        INIT_FCALL_BY_NAME                                       'permute'
          2        INIT_FCALL                                               'str_split'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $2      
          5        SEND_VAR_NO_REF_EX                                       $2
          6        SEND_VAL_EX                                              0
          7        STRLEN                                           ~3      !0
          8        SEND_VAL_EX                                              ~3
          9        DO_FCALL                                      0          
   31    10      > RETURN                                                   1

Function permute:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 11
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 11
Branch analysis from position: 30
Branch analysis from position: 11
filename:       /in/DSo4D
function name:  permute
number of ops:  31
compiled vars:  !0 = $arr, !1 = $i, !2 = $n, !3 = $j
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   10     3        IS_EQUAL                                                 !1, !2
          4      > JMPZ                                                     ~4, ->9
   11     5    >   INIT_FCALL_BY_NAME                                       'printArray'
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0          
   12     8      > RETURN                                                   null
   15     9    >   ASSIGN                                                   !3, !1
         10      > JMP                                                      ->28
   16    11    >   INIT_FCALL_BY_NAME                                       'swapArrayValues'
         12        SEND_VAR_EX                                              !0
         13        SEND_VAR_EX                                              !1
         14        SEND_VAR_EX                                              !3
         15        DO_FCALL                                      0          
   17    16        INIT_FCALL_BY_NAME                                       'permute'
         17        SEND_VAR_EX                                              !0
         18        ADD                                              ~8      !1, 1
         19        SEND_VAL_EX                                              ~8
         20        SEND_VAR_EX                                              !2
         21        DO_FCALL                                      0          
   18    22        INIT_FCALL_BY_NAME                                       'swapArrayValues'
         23        SEND_VAR_EX                                              !0
         24        SEND_VAR_EX                                              !1
         25        SEND_VAR_EX                                              !3
         26        DO_FCALL                                      0          
   15    27        ASSIGN_OP                                     1          !3, 1
         28    >   IS_SMALLER                                               !3, !2
         29      > JMPNZ                                                    ~12, ->11
   20    30    > > RETURN                                                   null

End of function permute

Function swaparrayvalues:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DSo4D
function name:  swapArrayValues
number of ops:  11
compiled vars:  !0 = $array, !1 = $i, !2 = $j, !3 = $tmp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   24     3        FETCH_DIM_R                                      ~4      !0, !1
          4        ASSIGN                                                   !3, ~4
   25     5        FETCH_DIM_R                                      ~7      !0, !2
          6        ASSIGN_DIM                                               !0, !1
          7        OP_DATA                                                  ~7
   26     8        ASSIGN_DIM                                               !0, !2
          9        OP_DATA                                                  !3
   27    10      > RETURN                                                   null

End of function swaparrayvalues

Function printarray:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DSo4D
function name:  printArray
number of ops:  8
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
   30     1        INIT_FCALL                                               'implode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 '+'
          4        DO_ICALL                                         $1      
          5        CONCAT                                           ~2      $1, '%0A'
          6        ECHO                                                     ~2
   31     7      > RETURN                                                   null

End of function printarray

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.06 ms | 1400 KiB | 17 Q