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

End of function get_combinations

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.68 ms | 1403 KiB | 22 Q