3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getNumsOdd(array $nums) { foreach($nums as $key => $num) { if ($num % 2) { (yield $num); } } } $i = 0; $gen = getNumsOdd([1,3,4,5,6]); while($gen->next()) { var_dump($num->current()); if (++$i == 10){ break; } } /*foreach(getNumsOdd([1,3,4,5,6]) as $key => $num) { echo $key . '=>' . $num.PHP_EOL; }*/
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 6
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 15
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 15
filename:       /in/n4ePD
function name:  (null)
number of ops:  19
compiled vars:  !0 = $i, !1 = $gen, !2 = $num
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   ASSIGN                                                   !0, 0
   11     1        INIT_FCALL                                               'getnumsodd'
          2        SEND_VAL                                                 <array>
          3        DO_FCALL                                      0  $4      
          4        ASSIGN                                                   !1, $4
   12     5      > JMP                                                      ->15
   13     6    >   INIT_FCALL                                               'var_dump'
          7        INIT_METHOD_CALL                                         !2, 'current'
          8        DO_FCALL                                      0  $6      
          9        SEND_VAR                                                 $6
         10        DO_ICALL                                                 
   14    11        PRE_INC                                          ~8      !0
         12        IS_EQUAL                                                 ~8, 10
         13      > JMPZ                                                     ~9, ->15
   15    14    > > JMP                                                      ->18
   12    15    >   INIT_METHOD_CALL                                         !1, 'next'
         16        DO_FCALL                                      0  $10     
         17      > JMPNZ                                                    $10, ->6
   21    18    > > RETURN                                                   1

Function getnumsodd:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 8
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 8
Branch analysis from position: 9
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 9
filename:       /in/n4ePD
function name:  getNumsOdd
number of ops:  11
compiled vars:  !0 = $nums, !1 = $num, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
    4     2      > FE_RESET_R                                       $3      !0, ->9
          3    > > FE_FETCH_R                                       ~4      $3, !1, ->9
          4    >   ASSIGN                                                   !2, ~4
    5     5        MOD                                              ~6      !1, 2
          6      > JMPZ                                                     ~6, ->8
    6     7    >   YIELD                                                    !1
    4     8    > > JMP                                                      ->3
          9    >   FE_FREE                                                  $3
    9    10      > GENERATOR_RETURN                                         

End of function getnumsodd

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.59 ms | 1394 KiB | 16 Q