3v4l.org

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

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

End of function getnumsodd

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.62 ms | 1403 KiB | 16 Q