3v4l.org

run code in 300+ PHP versions simultaneously
<?php function permute($base, $add) { $result = []; if (count($base) > 0) { foreach ($base as $val1) { if (count($add) > 0) { foreach ($add as $val2) { $result[] = array_merge($val1, $val2); } } else { $result = $base; } } } else { $result = $add; } return $result; } function getPermutations(array $optionSet) { $stuff = []; $permutations = []; $index = 0; foreach ($optionSet as $key => $set) { $stuff[$index] = []; foreach ($set as $code => $name) { array_push($stuff[$index], [$key => $code]); } $index++; } $count = count($stuff); for ($i = 0; $i < $count; $i++) { $temp = array_map( [ $this, "permute", ], [$permutations], [$stuff[$i]] ); $permutations = $temp[0]; } return $permutations; } $options = [ 'Condition' => [ 'nm' => 'Near Mint/Mint', 'sp' => 'Slightly Played', 'hp' => 'Heavily Played' ], 'Style' => [ 'normal' => 'Normal', 'foil' => 'Foil' ] ]; var_dump(getPermutations($options));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kiqj2
function name:  (null)
number of ops:  8
compiled vars:  !0 = $options
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   54     0  E >   ASSIGN                                                   !0, <array>
   67     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'getpermutations'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function permute:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 26
Branch analysis from position: 6
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 24
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 24
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 22
Branch analysis from position: 11
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 20
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 20
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 20
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kiqj2
function name:  permute
number of ops:  29
compiled vars:  !0 = $base, !1 = $add, !2 = $result, !3 = $val1, !4 = $val2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        ASSIGN                                                   !2, <array>
    6     3        COUNT                                            ~6      !0
          4        IS_SMALLER                                               0, ~6
          5      > JMPZ                                                     ~7, ->26
    7     6    > > FE_RESET_R                                       $8      !0, ->24
          7    > > FE_FETCH_R                                               $8, !3, ->24
    8     8    >   COUNT                                            ~9      !1
          9        IS_SMALLER                                               0, ~9
         10      > JMPZ                                                     ~10, ->22
    9    11    > > FE_RESET_R                                       $11     !1, ->20
         12    > > FE_FETCH_R                                               $11, !4, ->20
   10    13    >   INIT_FCALL                                               'array_merge'
         14        SEND_VAR                                                 !3
         15        SEND_VAR                                                 !4
         16        DO_ICALL                                         $13     
         17        ASSIGN_DIM                                               !2
         18        OP_DATA                                                  $13
    9    19      > JMP                                                      ->12
         20    >   FE_FREE                                                  $11
         21      > JMP                                                      ->23
   13    22    >   ASSIGN                                                   !2, !0
    7    23    > > JMP                                                      ->7
         24    >   FE_FREE                                                  $8
         25      > JMP                                                      ->27
   17    26    >   ASSIGN                                                   !2, !1
   20    27    > > RETURN                                                   !2
   21    28*     > RETURN                                                   null

End of function permute

Function getpermutations:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 22
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 22
Branch analysis from position: 6
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 19
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 19
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 19
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 44, Position 2 = 27
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 44, Position 2 = 27
Branch analysis from position: 44
Branch analysis from position: 27
Branch analysis from position: 22
filename:       /in/kiqj2
function name:  getPermutations
number of ops:  46
compiled vars:  !0 = $optionSet, !1 = $stuff, !2 = $permutations, !3 = $index, !4 = $set, !5 = $key, !6 = $name, !7 = $code, !8 = $count, !9 = $i, !10 = $temp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
   26     1        ASSIGN                                                   !1, <array>
   27     2        ASSIGN                                                   !2, <array>
   28     3        ASSIGN                                                   !3, 0
   29     4      > FE_RESET_R                                       $14     !0, ->22
          5    > > FE_FETCH_R                                       ~15     $14, !4, ->22
          6    >   ASSIGN                                                   !5, ~15
   30     7        ASSIGN_DIM                                               !1, !3
          8        OP_DATA                                                  <array>
   31     9      > FE_RESET_R                                       $18     !4, ->19
         10    > > FE_FETCH_R                                       ~19     $18, !6, ->19
         11    >   ASSIGN                                                   !7, ~19
   32    12        INIT_FCALL                                               'array_push'
         13        FETCH_DIM_W                                      $21     !1, !3
         14        SEND_REF                                                 $21
         15        INIT_ARRAY                                       ~22     !7, !5
         16        SEND_VAL                                                 ~22
         17        DO_ICALL                                                 
   31    18      > JMP                                                      ->10
         19    >   FE_FREE                                                  $18
   34    20        PRE_INC                                                  !3
   29    21      > JMP                                                      ->5
         22    >   FE_FREE                                                  $14
   36    23        COUNT                                            ~25     !1
         24        ASSIGN                                                   !8, ~25
   37    25        ASSIGN                                                   !9, 0
         26      > JMP                                                      ->42
   38    27    >   INIT_FCALL                                               'array_map'
   40    28        FETCH_THIS                                       ~28     
         29        INIT_ARRAY                                       ~29     ~28
   41    30        ADD_ARRAY_ELEMENT                                ~29     'permute'
         31        SEND_VAL                                                 ~29
   43    32        INIT_ARRAY                                       ~30     !2
         33        SEND_VAL                                                 ~30
   44    34        FETCH_DIM_R                                      ~31     !1, !9
         35        INIT_ARRAY                                       ~32     ~31
         36        SEND_VAL                                                 ~32
         37        DO_ICALL                                         $33     
   38    38        ASSIGN                                                   !10, $33
   46    39        FETCH_DIM_R                                      ~35     !10, 0
         40        ASSIGN                                                   !2, ~35
   37    41        PRE_INC                                                  !9
         42    >   IS_SMALLER                                               !9, !8
         43      > JMPNZ                                                    ~38, ->27
   49    44    > > RETURN                                                   !2
   50    45*     > RETURN                                                   null

End of function getpermutations

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
182.66 ms | 1398 KiB | 22 Q