3v4l.org

run code in 300+ PHP versions simultaneously
<?php function pc_permute($items, $perms = array()) { if (empty($items)) { echo join(' ', $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); pc_permute($newitems, $newperms); } } } $chars = "01234567890"; $arr = str_split($chars); #$arr = array('peter', 'paul', 'mary'); pc_permute($arr); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/P1sO4
function name:  (null)
number of ops:  9
compiled vars:  !0 = $chars, !1 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   ASSIGN                                                   !0, '01234567890'
   16     1        INIT_FCALL                                               'str_split'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !1, $3
   19     5        INIT_FCALL                                               'pc_permute'
          6        SEND_VAR                                                 !1
          7        DO_FCALL                                      0          
   20     8      > RETURN                                                   1

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

End of function pc_permute

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.19 ms | 1402 KiB | 22 Q