3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 8 => [ 'Blue', 'Red', 'Pink' ], 2 => [ 'S', 'M' ] ]; $combinations = [[]]; $comKeys = array_keys($data); for ($count = 0; $count < count($comKeys); $count++) { $tmp = []; foreach ($combinations as $v1) { foreach ($array[$comKeys[$count]] as $v2) $tmp[] = $v1 + [$comKeys[$count] => $v2]; } $combinations = $tmp; } print_r($combinations);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 8
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 23
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 23
Branch analysis from position: 11
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 21
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 21
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 21
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 8
Branch analysis from position: 29
Branch analysis from position: 8
Branch analysis from position: 23
filename:       /in/1D6vJ
function name:  (null)
number of ops:  33
compiled vars:  !0 = $array, !1 = $combinations, !2 = $comKeys, !3 = $data, !4 = $count, !5 = $tmp, !6 = $v1, !7 = $v2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   15     1        ASSIGN                                                   !1, <array>
   16     2        INIT_FCALL                                               'array_keys'
          3        SEND_VAR                                                 !3
          4        DO_ICALL                                         $10     
          5        ASSIGN                                                   !2, $10
   19     6        ASSIGN                                                   !4, 0
          7      > JMP                                                      ->26
   20     8    >   ASSIGN                                                   !5, <array>
   21     9      > FE_RESET_R                                       $14     !1, ->23
         10    > > FE_FETCH_R                                               $14, !6, ->23
   22    11    >   FETCH_DIM_R                                      ~15     !2, !4
         12        FETCH_DIM_R                                      ~16     !0, ~15
         13      > FE_RESET_R                                       $17     ~16, ->21
         14    > > FE_FETCH_R                                               $17, !7, ->21
   23    15    >   FETCH_DIM_R                                      ~19     !2, !4
         16        INIT_ARRAY                                       ~20     !7, ~19
         17        ADD                                              ~21     !6, ~20
         18        ASSIGN_DIM                                               !5
         19        OP_DATA                                                  ~21
   22    20      > JMP                                                      ->14
         21    >   FE_FREE                                                  $17
   21    22      > JMP                                                      ->10
         23    >   FE_FREE                                                  $14
   26    24        ASSIGN                                                   !1, !5
   19    25        PRE_INC                                                  !4
         26    >   COUNT                                            ~24     !2
         27        IS_SMALLER                                               !4, ~24
         28      > JMPNZ                                                    ~25, ->8
   29    29    >   INIT_FCALL                                               'print_r'
         30        SEND_VAR                                                 !1
         31        DO_ICALL                                                 
         32      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.47 ms | 1400 KiB | 17 Q