3v4l.org

run code in 300+ PHP versions simultaneously
<?php $items = range('a', 'g'); function permute($items, $perms = array( )) { if (empty($items)) { return($perms); } else { for ($i = count($items) - 1; $i >= 0; --$i) { $newitems = $items; $newperms = $perms; list($foo) = array_splice($newitems, $i, 1); array_unshift($newperms, $foo); permute($newitems, $newperms); } } } permute($items);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QmB8M
function name:  (null)
number of ops:  9
compiled vars:  !0 = $items
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'range'
          1        SEND_VAL                                                 'a'
          2        SEND_VAL                                                 'g'
          3        DO_ICALL                                         $1      
          4        ASSIGN                                                   !0, $1
   18     5        INIT_FCALL                                               'permute'
          6        SEND_VAR                                                 !0
          7        DO_FCALL                                      0          
          8      > RETURN                                                   1

Function permute:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 10
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 10
Branch analysis from position: 31
Branch analysis from position: 10
filename:       /in/QmB8M
function name:  permute
number of ops:  32
compiled vars:  !0 = $items, !1 = $perms, !2 = $i, !3 = $newitems, !4 = $newperms, !5 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
    5     2        ISSET_ISEMPTY_CV                                         !0
          3      > JMPZ                                                     ~6, ->6
    6     4    > > RETURN                                                   !1
          5*       JMP                                                      ->31
    8     6    >   COUNT                                            ~7      !0
          7        SUB                                              ~8      ~7, 1
          8        ASSIGN                                                   !2, ~8
          9      > JMP                                                      ->29
    9    10    >   ASSIGN                                                   !3, !0
   10    11        ASSIGN                                                   !4, !1
   11    12        INIT_FCALL                                               'array_splice'
         13        SEND_REF                                                 !3
         14        SEND_VAR                                                 !2
         15        SEND_VAL                                                 1
         16        DO_ICALL                                         $12     
         17        FETCH_LIST_R                                     $13     $12, 0
         18        ASSIGN                                                   !5, $13
         19        FREE                                                     $12
   12    20        INIT_FCALL                                               'array_unshift'
         21        SEND_REF                                                 !4
         22        SEND_VAR                                                 !5
         23        DO_ICALL                                                 
   13    24        INIT_FCALL_BY_NAME                                       'permute'
         25        SEND_VAR_EX                                              !3
         26        SEND_VAR_EX                                              !4
         27        DO_FCALL                                      0          
    8    28        PRE_DEC                                                  !2
         29    >   IS_SMALLER_OR_EQUAL                                      0, !2
         30      > JMPNZ                                                    ~18, ->10
   16    31    > > RETURN                                                   null

End of function permute

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
200.51 ms | 1403 KiB | 20 Q