3v4l.org

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

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

End of function pc_permute

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.98 ms | 1403 KiB | 20 Q