3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = array('A' => array(1, 2), 'B' => array(3, 4), 'C' => array(5)); function get_combinations($arrays) { $result = array(array()); foreach ($arrays as $property => $property_values) { $tmp = array(); foreach ($result as $result_item) { foreach ($property_values as $property_value) { $tmp[] = array_merge($result_item, array($property => $property_value)); } } $result = $tmp; } return $result; } var_dump(get_combinations($a));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/np8Du
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>
   21     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 = 77) Position 1 = 3, Position 2 = 23
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 23
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 20
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 20
Branch analysis from position: 8
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 18
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 18
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 18
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 20
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/np8Du
function name:  get_combinations
number of ops:  26
compiled vars:  !0 = $arrays, !1 = $result, !2 = $property_values, !3 = $property, !4 = $tmp, !5 = $result_item, !6 = $property_value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        ASSIGN                                                   !1, <array>
    9     2      > FE_RESET_R                                       $8      !0, ->23
          3    > > FE_FETCH_R                                       ~9      $8, !2, ->23
          4    >   ASSIGN                                                   !3, ~9
   10     5        ASSIGN                                                   !4, <array>
   11     6      > FE_RESET_R                                       $12     !1, ->20
          7    > > FE_FETCH_R                                               $12, !5, ->20
   12     8    > > FE_RESET_R                                       $13     !2, ->18
          9    > > FE_FETCH_R                                               $13, !6, ->18
   13    10    >   INIT_FCALL                                               'array_merge'
         11        SEND_VAR                                                 !5
         12        INIT_ARRAY                                       ~15     !6, !3
         13        SEND_VAL                                                 ~15
         14        DO_ICALL                                         $16     
         15        ASSIGN_DIM                                               !4
         16        OP_DATA                                                  $16
   12    17      > JMP                                                      ->9
         18    >   FE_FREE                                                  $13
   11    19      > JMP                                                      ->7
         20    >   FE_FREE                                                  $12
   16    21        ASSIGN                                                   !1, !4
    9    22      > JMP                                                      ->3
         23    >   FE_FREE                                                  $8
   18    24      > RETURN                                                   !1
   19    25*     > RETURN                                                   null

End of function get_combinations

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.29 ms | 1403 KiB | 18 Q