3v4l.org

run code in 300+ PHP versions simultaneously
<?php function genmer($gens) { foreach($gens as $gen) { while($gen->valid()) { yield $gen->current(); $gen->next(); } } } function gen_one_to_three() { for ($i = 1; $i <= 3; $i++) { // Note that $i is preserved between yields. yield $i; } } $merged = [$on, $two, $three]; foreach($merged as $m) { foreach($m as $g) { var_dump($g); } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 14
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 14
Branch analysis from position: 6
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 12
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 12
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 12
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/PbNrl
function name:  (null)
number of ops:  16
compiled vars:  !0 = $merged, !1 = $on, !2 = $two, !3 = $three, !4 = $m, !5 = $g
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   INIT_ARRAY                                       ~6      !1
          1        ADD_ARRAY_ELEMENT                                ~6      !2
          2        ADD_ARRAY_ELEMENT                                ~6      !3
          3        ASSIGN                                                   !0, ~6
   22     4      > FE_RESET_R                                       $8      !0, ->14
          5    > > FE_FETCH_R                                               $8, !4, ->14
   23     6    > > FE_RESET_R                                       $9      !4, ->12
          7    > > FE_FETCH_R                                               $9, !5, ->12
   24     8    >   INIT_FCALL                                               'var_dump'
          9        SEND_VAR                                                 !5
         10        DO_ICALL                                                 
   23    11      > JMP                                                      ->7
         12    >   FE_FREE                                                  $9
   22    13      > JMP                                                      ->5
         14    >   FE_FREE                                                  $8
   26    15      > RETURN                                                   1

Function genmer:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 14
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 14
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 5
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 5
Branch analysis from position: 13
Branch analysis from position: 5
Branch analysis from position: 14
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 14
filename:       /in/PbNrl
function name:  genmer
number of ops:  16
compiled vars:  !0 = $gens, !1 = $gen
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
    4     2      > FE_RESET_R                                       $2      !0, ->14
          3    > > FE_FETCH_R                                               $2, !1, ->14
    5     4    > > JMP                                                      ->10
    6     5    >   INIT_METHOD_CALL                                         !1, 'current'
          6        DO_FCALL                                      0  $3      
          7        YIELD                                                    $3
    7     8        INIT_METHOD_CALL                                         !1, 'next'
          9        DO_FCALL                                      0          
    5    10    >   INIT_METHOD_CALL                                         !1, 'valid'
         11        DO_FCALL                                      0  $6      
         12      > JMPNZ                                                    $6, ->5
    4    13    > > JMP                                                      ->3
         14    >   FE_FREE                                                  $2
   10    15      > GENERATOR_RETURN                                         

End of function genmer

Function gen_one_to_three:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 7, Position 2 = 3
Branch analysis from position: 7
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 7, Position 2 = 3
Branch analysis from position: 7
Branch analysis from position: 3
filename:       /in/PbNrl
function name:  gen_one_to_three
number of ops:  8
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   GENERATOR_CREATE                                         
   13     1        ASSIGN                                                   !0, 1
          2      > JMP                                                      ->5
   15     3    >   YIELD                                                    !0
   13     4        PRE_INC                                                  !0
          5    >   IS_SMALLER_OR_EQUAL                                      !0, 3
          6      > JMPNZ                                                    ~4, ->3
   17     7    > > GENERATOR_RETURN                                         

End of function gen_one_to_three

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.13 ms | 1405 KiB | 15 Q