3v4l.org

run code in 300+ PHP versions simultaneously
<?php function generate($elements, $maxvalue) { if ($elements == 0) return array(); $result = array(); foreach (range(1, $maxvalue) as $el) { $result[] = array($el); } foreach (range(1, $maxvalue) as $el) { foreach (generate($elements - 1, $maxvalue) as $arr) { $result[] = array($el, ...$arr); } } return $result; } $combs = generate(3, 3); print_r($combs);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XHheY
function name:  (null)
number of ops:  9
compiled vars:  !0 = $combs
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL                                               'generate'
          1        SEND_VAL                                                 3
          2        SEND_VAL                                                 3
          3        DO_FCALL                                      0  $1      
          4        ASSIGN                                                   !0, $1
   19     5        INIT_FCALL                                               'print_r'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Function generate:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 16
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 16
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 16
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 = 77) Position 1 = 29, Position 2 = 35
Branch analysis from position: 29
2 jumps found. (Code = 78) Position 1 = 30, Position 2 = 35
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 35
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
Branch analysis from position: 16
filename:       /in/XHheY
function name:  generate
number of ops:  40
compiled vars:  !0 = $elements, !1 = $maxvalue, !2 = $result, !3 = $el, !4 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        IS_EQUAL                                                 !0, 0
          3      > JMPZ                                                     ~5, ->5
          4    > > RETURN                                                   <array>
    5     5    >   ASSIGN                                                   !2, <array>
    6     6        INIT_FCALL                                               'range'
          7        SEND_VAL                                                 1
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                         $7      
         10      > FE_RESET_R                                       $8      $7, ->16
         11    > > FE_FETCH_R                                               $8, !3, ->16
    7    12    >   INIT_ARRAY                                       ~10     !3
         13        ASSIGN_DIM                                               !2
         14        OP_DATA                                                  ~10
    6    15      > JMP                                                      ->11
         16    >   FE_FREE                                                  $8
    9    17        INIT_FCALL                                               'range'
         18        SEND_VAL                                                 1
         19        SEND_VAR                                                 !1
         20        DO_ICALL                                         $11     
         21      > FE_RESET_R                                       $12     $11, ->37
         22    > > FE_FETCH_R                                               $12, !3, ->37
   10    23    >   INIT_FCALL_BY_NAME                                       'generate'
         24        SUB                                              ~13     !0, 1
         25        SEND_VAL_EX                                              ~13
         26        SEND_VAR_EX                                              !1
         27        DO_FCALL                                      0  $14     
         28      > FE_RESET_R                                       $15     $14, ->35
         29    > > FE_FETCH_R                                               $15, !4, ->35
   11    30    >   INIT_ARRAY                                       ~17     !3
         31        ADD_ARRAY_UNPACK                                 ~17     !4
         32        ASSIGN_DIM                                               !2
         33        OP_DATA                                                  ~17
   10    34      > JMP                                                      ->29
         35    >   FE_FREE                                                  $15
    9    36      > JMP                                                      ->22
         37    >   FE_FREE                                                  $12
   14    38      > RETURN                                                   !2
   15    39*     > RETURN                                                   null

End of function generate

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
204.06 ms | 1008 KiB | 16 Q