3v4l.org

run code in 300+ PHP versions simultaneously
<?php $result = []; function getNumsOdd(array $nums, array &$result) { foreach($nums as $num) { iterator_apply(get2Nums($num, $result),function(){}); yield; } } function get2Nums(array $nums, array &$result) { foreach($nums as $num) { if ($num % 2) { $result[$key] = $num; yield; } } } foreach(getNumsOdd([[1,3,4,5,6],[7,8,9,10]], $result) as $x); print_r($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 8
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/gLJk5
function name:  (null)
number of ops:  13
compiled vars:  !0 = $result, !1 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   20     1        INIT_FCALL                                               'getnumsodd'
          2        SEND_VAL                                                 <array>
          3        SEND_REF                                                 !0
          4        DO_FCALL                                      0  $3      
          5      > FE_RESET_R                                       $4      $3, ->8
          6    > > FE_FETCH_R                                               $4, !1, ->8
          7    > > JMP                                                      ->6
          8    >   FE_FREE                                                  $4
   22     9        INIT_FCALL                                               'print_r'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

Function getnumsodd:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 16
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 16
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 16
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 16
filename:       /in/gLJk5
function name:  getNumsOdd
number of ops:  18
compiled vars:  !0 = $nums, !1 = $result, !2 = $num
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                                       $3      !0, ->16
          4    > > FE_FETCH_R                                               $3, !2, ->16
    6     5    >   INIT_FCALL                                               'iterator_apply'
          6        INIT_FCALL_BY_NAME                                       'get2Nums'
          7        SEND_VAR_EX                                              !2
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0  $4      
         10        SEND_VAR                                                 $4
         11        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FgLJk5%3A6%240'
         12        SEND_VAL                                                 ~5
         13        DO_ICALL                                                 
    7    14        YIELD                                                    
    5    15      > JMP                                                      ->4
         16    >   FE_FREE                                                  $3
    9    17      > GENERATOR_RETURN                                         

End of function getnumsodd

Function %00%7Bclosure%7D%2Fin%2FgLJk5%3A6%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gLJk5
function name:  {closure}
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FgLJk5%3A6%240

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

End of function get2nums

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.88 ms | 1403 KiB | 18 Q