3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = array(array(1, 2), array(3, 4), array(5)); function get_combinations($arrays) { $result = array(array()); $count = count($arrays); if($count > 2) { $array_merg = get_combinations(array_slice($arrays, 1)); } else { $array_merg = $arrays[1]; } print_r($arrays[0]); print_r($array_merg); $tmp = array(); foreach($arrays[0] as $arele1) { foreach($array_merg as $arele2) { print_r($arele2); if(is_array($arele2)) { $tmp[] = array_unshift($arele2,$arele1); } else { $tmp[] = array($arele1,$arele2); } } } print_r($tmp); return $tmp; } var_dump(get_combinations($a));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LgeZQ
function name:  (null)
number of ops:  8
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   31     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'get_combinations'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function get_combinations:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 15
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
2 jumps found. (Code = 77) Position 1 = 27, Position 2 = 49
Branch analysis from position: 27
2 jumps found. (Code = 78) Position 1 = 28, Position 2 = 49
Branch analysis from position: 28
2 jumps found. (Code = 77) Position 1 = 29, Position 2 = 47
Branch analysis from position: 29
2 jumps found. (Code = 78) Position 1 = 30, Position 2 = 47
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 42
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
Branch analysis from position: 47
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 49
Branch analysis from position: 15
2 jumps found. (Code = 77) Position 1 = 27, Position 2 = 49
Branch analysis from position: 27
Branch analysis from position: 49
filename:       /in/LgeZQ
function name:  get_combinations
number of ops:  55
compiled vars:  !0 = $arrays, !1 = $result, !2 = $count, !3 = $array_merg, !4 = $tmp, !5 = $arele1, !6 = $arele2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        ASSIGN                                                   !1, <array>
    8     2        COUNT                                            ~8      !0
          3        ASSIGN                                                   !2, ~8
    9     4        IS_SMALLER                                               2, !2
          5      > JMPZ                                                     ~10, ->15
   10     6    >   INIT_FCALL_BY_NAME                                       'get_combinations'
          7        INIT_FCALL                                               'array_slice'
          8        SEND_VAR                                                 !0
          9        SEND_VAL                                                 1
         10        DO_ICALL                                         $11     
         11        SEND_VAR_NO_REF_EX                                       $11
         12        DO_FCALL                                      0  $12     
         13        ASSIGN                                                   !3, $12
         14      > JMP                                                      ->17
   12    15    >   FETCH_DIM_R                                      ~14     !0, 1
         16        ASSIGN                                                   !3, ~14
   14    17    >   INIT_FCALL                                               'print_r'
         18        FETCH_DIM_R                                      ~16     !0, 0
         19        SEND_VAL                                                 ~16
         20        DO_ICALL                                                 
   15    21        INIT_FCALL                                               'print_r'
         22        SEND_VAR                                                 !3
         23        DO_ICALL                                                 
   16    24        ASSIGN                                                   !4, <array>
   17    25        FETCH_DIM_R                                      ~20     !0, 0
         26      > FE_RESET_R                                       $21     ~20, ->49
         27    > > FE_FETCH_R                                               $21, !5, ->49
   18    28    > > FE_RESET_R                                       $22     !3, ->47
         29    > > FE_FETCH_R                                               $22, !6, ->47
   19    30    >   INIT_FCALL                                               'print_r'
         31        SEND_VAR                                                 !6
         32        DO_ICALL                                                 
   20    33        TYPE_CHECK                                  128          !6
         34      > JMPZ                                                     ~24, ->42
   21    35    >   INIT_FCALL                                               'array_unshift'
         36        SEND_REF                                                 !6
         37        SEND_VAR                                                 !5
         38        DO_ICALL                                         $26     
         39        ASSIGN_DIM                                               !4
         40        OP_DATA                                                  $26
         41      > JMP                                                      ->46
   23    42    >   INIT_ARRAY                                       ~28     !5
         43        ADD_ARRAY_ELEMENT                                ~28     !6
         44        ASSIGN_DIM                                               !4
         45        OP_DATA                                                  ~28
   18    46    > > JMP                                                      ->29
         47    >   FE_FREE                                                  $22
   17    48      > JMP                                                      ->27
         49    >   FE_FREE                                                  $21
   27    50        INIT_FCALL                                               'print_r'
         51        SEND_VAR                                                 !4
         52        DO_ICALL                                                 
   28    53      > RETURN                                                   !4
   29    54*     > RETURN                                                   null

End of function get_combinations

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.24 ms | 1403 KiB | 22 Q