3v4l.org

run code in 300+ PHP versions simultaneously
<?php function generate_comb($pos, &$res, $nr) { global $comb; if ((strlen($res) + 1) / 2 == $nr or $nr == 0) { print_r('{' . $res . '}'); echo "\n"; } else { if ((strlen($res) + 1) / 2 < $nr) { if ($res != '') { $res = $res . ','; } for ($i = $pos + 1; $i < count($comb); $i++) { $var = $res . $comb[$i]; generate_comb($i, $var, $nr); } } } } $comb = array(1, 2, 3, 4, 5); $pos = -1; $res = ''; for ($i = 0; $i <= count($comb); $i++) { generate_comb($pos, $res, $i); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 5
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 5
Branch analysis from position: 14
Branch analysis from position: 5
filename:       /in/lr7k1
function name:  (null)
number of ops:  15
compiled vars:  !0 = $comb, !1 = $pos, !2 = $res, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   ASSIGN                                                   !0, <array>
   27     1        ASSIGN                                                   !1, -1
   28     2        ASSIGN                                                   !2, ''
   29     3        ASSIGN                                                   !3, 0
          4      > JMP                                                      ->11
   30     5    >   INIT_FCALL                                               'generate_comb'
          6        SEND_VAR                                                 !1
          7        SEND_REF                                                 !2
          8        SEND_VAR                                                 !3
          9        DO_FCALL                                      0          
   29    10        PRE_INC                                                  !3
         11    >   COUNT                                            ~10     !0
         12        IS_SMALLER_OR_EQUAL                                      !3, ~10
         13      > JMPNZ                                                    ~11, ->5
   31    14    > > RETURN                                                   1

Function generate_comb:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 19
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 43
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 28
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 31
Branch analysis from position: 43
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 31
Branch analysis from position: 43
Branch analysis from position: 31
Branch analysis from position: 28
Branch analysis from position: 43
Branch analysis from position: 11
filename:       /in/lr7k1
function name:  generate_comb
number of ops:  44
compiled vars:  !0 = $pos, !1 = $res, !2 = $nr, !3 = $comb, !4 = $i, !5 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    5     3        BIND_GLOBAL                                              !3, 'comb'
    7     4        STRLEN                                           ~6      !1
          5        ADD                                              ~7      ~6, 1
          6        DIV                                              ~8      ~7, 2
          7        IS_EQUAL                                         ~9      !2, ~8
          8      > JMPNZ_EX                                         ~9      ~9, ->11
          9    >   IS_EQUAL                                         ~10     !2, 0
         10        BOOL                                             ~9      ~10
         11    > > JMPZ                                                     ~9, ->19
    8    12    >   INIT_FCALL                                               'print_r'
         13        CONCAT                                           ~11     '%7B', !1
         14        CONCAT                                           ~12     ~11, '%7D'
         15        SEND_VAL                                                 ~12
         16        DO_ICALL                                                 
    9    17        ECHO                                                     '%0A'
         18      > JMP                                                      ->43
   11    19    >   STRLEN                                           ~14     !1
         20        ADD                                              ~15     ~14, 1
         21        DIV                                              ~16     ~15, 2
         22        IS_SMALLER                                               ~16, !2
         23      > JMPZ                                                     ~17, ->43
   12    24    >   IS_NOT_EQUAL                                             !1, ''
         25      > JMPZ                                                     ~18, ->28
   13    26    >   CONCAT                                           ~19     !1, '%2C'
         27        ASSIGN                                                   !1, ~19
   16    28    >   ADD                                              ~21     !0, 1
         29        ASSIGN                                                   !4, ~21
         30      > JMP                                                      ->40
   17    31    >   FETCH_DIM_R                                      ~23     !3, !4
         32        CONCAT                                           ~24     !1, ~23
         33        ASSIGN                                                   !5, ~24
   18    34        INIT_FCALL_BY_NAME                                       'generate_comb'
         35        SEND_VAR_EX                                              !4
         36        SEND_VAR_EX                                              !5
         37        SEND_VAR_EX                                              !2
         38        DO_FCALL                                      0          
   16    39        PRE_INC                                                  !4
         40    >   COUNT                                            ~28     !3
         41        IS_SMALLER                                               !4, ~28
         42      > JMPNZ                                                    ~29, ->31
   23    43    > > RETURN                                                   null

End of function generate_comb

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.14 ms | 1403 KiB | 16 Q