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; } } $on = gen_one_to_three(); $two = gen_one_to_three(); $three = gen_one_to_three(); $merged = [$on, $two, $three]; foreach($merged as $m) { foreach($m as $g) { var_dump($m); } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 23
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 23
Branch analysis from position: 15
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 21
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 21
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 21
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/eXk4A
function name:  (null)
number of ops:  25
compiled vars:  !0 = $on, !1 = $two, !2 = $three, !3 = $merged, !4 = $m, !5 = $g
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   INIT_FCALL                                               'gen_one_to_three'
          1        DO_FCALL                                      0  $6      
          2        ASSIGN                                                   !0, $6
   20     3        INIT_FCALL                                               'gen_one_to_three'
          4        DO_FCALL                                      0  $8      
          5        ASSIGN                                                   !1, $8
   21     6        INIT_FCALL                                               'gen_one_to_three'
          7        DO_FCALL                                      0  $10     
          8        ASSIGN                                                   !2, $10
   23     9        INIT_ARRAY                                       ~12     !0
         10        ADD_ARRAY_ELEMENT                                ~12     !1
         11        ADD_ARRAY_ELEMENT                                ~12     !2
         12        ASSIGN                                                   !3, ~12
   25    13      > FE_RESET_R                                       $14     !3, ->23
         14    > > FE_FETCH_R                                               $14, !4, ->23
   26    15    > > FE_RESET_R                                       $15     !4, ->21
         16    > > FE_FETCH_R                                               $15, !5, ->21
   27    17    >   INIT_FCALL                                               'var_dump'
         18        SEND_VAR                                                 !4
         19        DO_ICALL                                                 
   26    20      > JMP                                                      ->16
         21    >   FE_FREE                                                  $15
   25    22      > JMP                                                      ->14
         23    >   FE_FREE                                                  $14
   29    24      > 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/eXk4A
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/eXk4A
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:
154.05 ms | 1403 KiB | 18 Q