3v4l.org

run code in 300+ PHP versions simultaneously
<?php $items = range('a', 'g'); function permute($items, $perms = array( )) { if (empty($items)) { var_dump($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/fI5hC
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 = 8
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 12
Branch analysis from position: 33
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 12
Branch analysis from position: 33
Branch analysis from position: 12
filename:       /in/fI5hC
function name:  permute
number of ops:  34
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, ->8
    6     4    >   INIT_FCALL                                               'var_dump'
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                                 
          7      > JMP                                                      ->33
    8     8    >   COUNT                                            ~8      !0
          9        SUB                                              ~9      ~8, 1
         10        ASSIGN                                                   !2, ~9
         11      > JMP                                                      ->31
    9    12    >   ASSIGN                                                   !3, !0
   10    13        ASSIGN                                                   !4, !1
   11    14        INIT_FCALL                                               'array_splice'
         15        SEND_REF                                                 !3
         16        SEND_VAR                                                 !2
         17        SEND_VAL                                                 1
         18        DO_ICALL                                         $13     
         19        FETCH_LIST_R                                     $14     $13, 0
         20        ASSIGN                                                   !5, $14
         21        FREE                                                     $13
   12    22        INIT_FCALL                                               'array_unshift'
         23        SEND_REF                                                 !4
         24        SEND_VAR                                                 !5
         25        DO_ICALL                                                 
   13    26        INIT_FCALL_BY_NAME                                       'permute'
         27        SEND_VAR_EX                                              !3
         28        SEND_VAR_EX                                              !4
         29        DO_FCALL                                      0          
    8    30        PRE_DEC                                                  !2
         31    >   IS_SMALLER_OR_EQUAL                                      0, !2
         32      > JMPNZ                                                    ~19, ->12
   16    33    > > RETURN                                                   null

End of function permute

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.01 ms | 1403 KiB | 22 Q