3v4l.org

run code in 300+ PHP versions simultaneously
<?php $products = [1, 2, 3, 4, 5]; $vendors = ["Amazon", "Newegg", "Frys"]; $product_combinations = array(); function pc_permute($items, &$combinations, $perms = array()) { if (empty($items)) { $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, $combinations, $newperms); } } } // Build product combinations pc_permute($products, $product_combinations); // Build vendor combinations var_dump($product_combinations);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZkiIE
function name:  (null)
number of ops:  11
compiled vars:  !0 = $products, !1 = $vendors, !2 = $product_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>
   22     3        INIT_FCALL                                               'pc_permute'
          4        SEND_VAR                                                 !0
          5        SEND_REF                                                 !2
          6        DO_FCALL                                      0          
   28     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

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

End of function pc_permute

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.55 ms | 1403 KiB | 20 Q