3v4l.org

run code in 300+ PHP versions simultaneously
<?php function variations($digits, $prefix = '') { $result = []; for ($i = 1; $i <= 3; $i++) { $variation = $prefix . $i; if ($digits > 1) { $result = array_merge($result, variations($digits - 1, $variation)); } else { $result[] = $variation; } } return $result; } print_r(variations(1));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LBrjA
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   INIT_FCALL                                               'print_r'
          1        INIT_FCALL                                               'variations'
          2        SEND_VAL                                                 1
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
          6      > RETURN                                                   1

Function variations:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 5
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 20
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 5
Branch analysis from position: 25
Branch analysis from position: 5
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 5
Branch analysis from position: 25
Branch analysis from position: 5
filename:       /in/LBrjA
function name:  variations
number of ops:  27
compiled vars:  !0 = $digits, !1 = $prefix, !2 = $result, !3 = $i, !4 = $variation
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      ''
    4     2        ASSIGN                                                   !2, <array>
    6     3        ASSIGN                                                   !3, 1
          4      > JMP                                                      ->23
    7     5    >   CONCAT                                           ~7      !1, !3
          6        ASSIGN                                                   !4, ~7
    9     7        IS_SMALLER                                               1, !0
          8      > JMPZ                                                     ~9, ->20
   10     9    >   INIT_FCALL                                               'array_merge'
         10        SEND_VAR                                                 !2
         11        INIT_FCALL_BY_NAME                                       'variations'
         12        SUB                                              ~10     !0, 1
         13        SEND_VAL_EX                                              ~10
         14        SEND_VAR_EX                                              !4
         15        DO_FCALL                                      0  $11     
         16        SEND_VAR                                                 $11
         17        DO_ICALL                                         $12     
         18        ASSIGN                                                   !2, $12
    9    19      > JMP                                                      ->22
   12    20    >   ASSIGN_DIM                                               !2
         21        OP_DATA                                                  !4
    6    22    >   PRE_INC                                                  !3
         23    >   IS_SMALLER_OR_EQUAL                                      !3, 3
         24      > JMPNZ                                                    ~16, ->5
   16    25    > > RETURN                                                   !2
   17    26*     > RETURN                                                   null

End of function variations

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.48 ms | 1010 KiB | 16 Q