3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getCombinations(...$arrays) { $result = [[]]; foreach ($arrays as $property => $property_values) { $tmp = []; foreach ($result as $result_item) { foreach ($property_values as $property_value) { $tmp[] = array_merge($result_item, [$property => $property_value]); } } $result = $tmp; } return $result; } $atrs_ref = ['p', 'm', 'g']; $colors=['blanco', 'negro', 'rojo']; $sizes=['corta', 'larga'] ; print_r(getCombinations($atrs_ref, $colors, $sizes));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0H5ST
function name:  (null)
number of ops:  12
compiled vars:  !0 = $atrs_ref, !1 = $colors, !2 = $sizes
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   ASSIGN                                                   !0, <array>
   22     1        ASSIGN                                                   !1, <array>
   23     2        ASSIGN                                                   !2, <array>
   24     3        INIT_FCALL                                               'print_r'
          4        INIT_FCALL                                               'getcombinations'
          5        SEND_VAR                                                 !0
          6        SEND_VAR                                                 !1
          7        SEND_VAR                                                 !2
          8        DO_FCALL                                      0  $6      
          9        SEND_VAR                                                 $6
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

Function getcombinations:
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/0H5ST
function name:  getCombinations
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
-------------------------------------------------------------------------------------
    5     0  E >   RECV_VARIADIC                                    !0      
    7     1        ASSIGN                                                   !1, <array>
    8     2      > FE_RESET_R                                       $8      !0, ->23
          3    > > FE_FETCH_R                                       ~9      $8, !2, ->23
          4    >   ASSIGN                                                   !3, ~9
    9     5        ASSIGN                                                   !4, <array>
   10     6      > FE_RESET_R                                       $12     !1, ->20
          7    > > FE_FETCH_R                                               $12, !5, ->20
   11     8    > > FE_RESET_R                                       $13     !2, ->18
          9    > > FE_FETCH_R                                               $13, !6, ->18
   12    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
   11    17      > JMP                                                      ->9
         18    >   FE_FREE                                                  $13
   10    19      > JMP                                                      ->7
         20    >   FE_FREE                                                  $12
   15    21        ASSIGN                                                   !1, !4
    8    22      > JMP                                                      ->3
         23    >   FE_FREE                                                  $8
   17    24      > RETURN                                                   !1
   18    25*     > RETURN                                                   null

End of function getcombinations

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.52 ms | 1018 KiB | 16 Q