3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); /** * @param array $elements * * @return Generator */ function gen2(array $elements): \Generator { for ($num = count($elements), $i = pow(2, $num) - 1; $i >= 1; $i -= 2) { $r = []; for ($j = 0; $j < $num; $j += 1) { if ($i & (1 << ($num - $j - 1))) { $r[] = $elements[$j]; } } yield $r; } } foreach (gen2(['O', 'U', 'W', 'P', 'template']) as $path) { echo implode(' / ', $path), "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/grKXo
function name:  (null)
number of ops:  14
compiled vars:  !0 = $path
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   INIT_FCALL                                               'gen2'
          1        SEND_VAL                                                 <array>
          2        DO_FCALL                                      0  $1      
          3      > FE_RESET_R                                       $2      $1, ->12
          4    > > FE_FETCH_R                                               $2, !0, ->12
   24     5    >   INIT_FCALL                                               'implode'
          6        SEND_VAL                                                 '+%2F+'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $3      
          9        ECHO                                                     $3
         10        ECHO                                                     '%0A'
   23    11      > JMP                                                      ->4
         12    >   FE_FREE                                                  $2
   25    13      > RETURN                                                   1

Function gen2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 11
Branch analysis from position: 29
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 14
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 11
Branch analysis from position: 29
Branch analysis from position: 11
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 22
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 14
Branch analysis from position: 25
Branch analysis from position: 14
Branch analysis from position: 22
filename:       /in/grKXo
function name:  gen2
number of ops:  30
compiled vars:  !0 = $elements, !1 = $num, !2 = $i, !3 = $r, !4 = $j
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
   11     2        COUNT                                            ~5      !0
          3        ASSIGN                                                   !1, ~5
          4        INIT_FCALL                                               'pow'
          5        SEND_VAL                                                 2
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $7      
          8        SUB                                              ~8      $7, 1
          9        ASSIGN                                                   !2, ~8
         10      > JMP                                                      ->27
   12    11    >   ASSIGN                                                   !3, <array>
   13    12        ASSIGN                                                   !4, 0
         13      > JMP                                                      ->23
   14    14    >   SUB                                              ~12     !1, !4
         15        SUB                                              ~13     ~12, 1
         16        SL                                               ~14     1, ~13
         17        BW_AND                                           ~15     !2, ~14
         18      > JMPZ                                                     ~15, ->22
   15    19    >   FETCH_DIM_R                                      ~17     !0, !4
         20        ASSIGN_DIM                                               !3
         21        OP_DATA                                                  ~17
   13    22    >   ASSIGN_OP                                     1          !4, 1
         23    >   IS_SMALLER                                               !4, !1
         24      > JMPNZ                                                    ~19, ->14
   19    25    >   YIELD                                                    !3
   11    26        ASSIGN_OP                                     2          !2, 2
         27    >   IS_SMALLER_OR_EQUAL                                      1, !2
         28      > JMPNZ                                                    ~22, ->11
   21    29    > > GENERATOR_RETURN                                         

End of function gen2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.58 ms | 1019 KiB | 16 Q