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]; } $tmp = array(); foreach($arrays[0] as $arele1) { foreach($array_merg as $arele2) { if(is_array($arele2)) { $tmp[] = array_unshift($arele2,$arele1); } else { $tmp[] = array($arele1,$arele2); } } } 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/mCrTM
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>
   27     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 = 20, Position 2 = 39
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 39
Branch analysis from position: 21
2 jumps found. (Code = 77) Position 1 = 22, Position 2 = 37
Branch analysis from position: 22
2 jumps found. (Code = 78) Position 1 = 23, Position 2 = 37
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 32
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 37
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
Branch analysis from position: 15
2 jumps found. (Code = 77) Position 1 = 20, Position 2 = 39
Branch analysis from position: 20
Branch analysis from position: 39
filename:       /in/mCrTM
function name:  get_combinations
number of ops:  42
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    >   ASSIGN                                                   !4, <array>
   15    18        FETCH_DIM_R                                      ~17     !0, 0
         19      > FE_RESET_R                                       $18     ~17, ->39
         20    > > FE_FETCH_R                                               $18, !5, ->39
   16    21    > > FE_RESET_R                                       $19     !3, ->37
         22    > > FE_FETCH_R                                               $19, !6, ->37
   17    23    >   TYPE_CHECK                                  128          !6
         24      > JMPZ                                                     ~20, ->32
   18    25    >   INIT_FCALL                                               'array_unshift'
         26        SEND_REF                                                 !6
         27        SEND_VAR                                                 !5
         28        DO_ICALL                                         $22     
         29        ASSIGN_DIM                                               !4
         30        OP_DATA                                                  $22
         31      > JMP                                                      ->36
   20    32    >   INIT_ARRAY                                       ~24     !5
         33        ADD_ARRAY_ELEMENT                                ~24     !6
         34        ASSIGN_DIM                                               !4
         35        OP_DATA                                                  ~24
   16    36    > > JMP                                                      ->22
         37    >   FE_FREE                                                  $19
   15    38      > JMP                                                      ->20
         39    >   FE_FREE                                                  $18
   24    40      > RETURN                                                   !4
   25    41*     > RETURN                                                   null

End of function get_combinations

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.7 ms | 1403 KiB | 20 Q