3v4l.org

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

End of function permute

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.64 ms | 1407 KiB | 22 Q