3v4l.org

run code in 300+ PHP versions simultaneously
<?php 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; } $in = [ 1 => 'мама', 3 => 'раму', 7 => 'раму', 8 => 'мыла', 13 => 'мама', ]; $flipped = []; foreach ($in as $key => $value) { $flipped[$value][] = $key; } $flipped = array_values($flipped); $result = get_combinations($flipped); var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/gSGC0
function name:  (null)
number of ops:  22
compiled vars:  !0 = $in, !1 = $flipped, !2 = $value, !3 = $key, !4 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ASSIGN                                                   !0, <array>
   25     1        ASSIGN                                                   !1, <array>
   26     2      > FE_RESET_R                                       $7      !0, ->9
          3    > > FE_FETCH_R                                       ~8      $7, !2, ->9
          4    >   ASSIGN                                                   !3, ~8
   27     5        FETCH_DIM_W                                      $10     !1, !2
          6        ASSIGN_DIM                                               $10
          7        OP_DATA                                                  !3
   26     8      > JMP                                                      ->3
          9    >   FE_FREE                                                  $7
   29    10        INIT_FCALL                                               'array_values'
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                         $12     
         13        ASSIGN                                                   !1, $12
   30    14        INIT_FCALL                                               'get_combinations'
         15        SEND_VAR                                                 !1
         16        DO_FCALL                                      0  $14     
         17        ASSIGN                                                   !4, $14
   31    18        INIT_FCALL                                               'var_export'
         19        SEND_VAR                                                 !4
         20        DO_ICALL                                                 
         21      > 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/gSGC0
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
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, <array>
    5     2      > FE_RESET_R                                       $8      !0, ->23
          3    > > FE_FETCH_R                                       ~9      $8, !2, ->23
          4    >   ASSIGN                                                   !3, ~9
    6     5        ASSIGN                                                   !4, <array>
    7     6      > FE_RESET_R                                       $12     !1, ->20
          7    > > FE_FETCH_R                                               $12, !5, ->20
    8     8    > > FE_RESET_R                                       $13     !2, ->18
          9    > > FE_FETCH_R                                               $13, !6, ->18
    9    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
    8    17      > JMP                                                      ->9
         18    >   FE_FREE                                                  $13
    7    19      > JMP                                                      ->7
         20    >   FE_FREE                                                  $12
   12    21        ASSIGN                                                   !1, !4
    5    22      > JMP                                                      ->3
         23    >   FE_FREE                                                  $8
   14    24      > RETURN                                                   !1
   15    25*     > RETURN                                                   null

End of function get_combinations

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.2 ms | 1007 KiB | 17 Q