3v4l.org

run code in 300+ PHP versions simultaneously
<?php $products = [1, 2, 3, 4, 5]; $vendors = ["Amazon", "Newegg", "Frys"]; function pc_permute($items, $perms = array()) { if (empty($items)) { //echo join(' ', $perms) . "</br>"; 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); pc_permute($newitems, $newperms); } } } var_dump(pc_permute($products));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KkVKZ
function name:  (null)
number of ops:  9
compiled vars:  !0 = $products, !1 = $vendors
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
   23     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'pc_permute'
          4        SEND_VAR                                                 !0
          5        DO_FCALL                                      0  $4      
          6        SEND_VAR                                                 $4
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Function pc_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/KkVKZ
function name:  pc_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
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
    9     2        ISSET_ISEMPTY_CV                                         !0
          3      > JMPZ                                                     ~6, ->6
   11     4    > > RETURN                                                   !1
          5*       JMP                                                      ->31
   13     6    >   COUNT                                            ~7      !0
          7        SUB                                              ~8      ~7, 1
          8        ASSIGN                                                   !2, ~8
          9      > JMP                                                      ->29
   14    10    >   ASSIGN                                                   !3, !0
   15    11        ASSIGN                                                   !4, !1
   16    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
   17    20        INIT_FCALL                                               'array_unshift'
         21        SEND_REF                                                 !4
         22        SEND_VAR                                                 !5
         23        DO_ICALL                                                 
   18    24        INIT_FCALL_BY_NAME                                       'pc_permute'
         25        SEND_VAR_EX                                              !3
         26        SEND_VAR_EX                                              !4
         27        DO_FCALL                                      0          
   13    28        PRE_DEC                                                  !2
         29    >   IS_SMALLER_OR_EQUAL                                      0, !2
         30      > JMPNZ                                                    ~18, ->10
   21    31    > > RETURN                                                   null

End of function pc_permute

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.85 ms | 1403 KiB | 20 Q