3v4l.org

run code in 500+ PHP versions simultaneously
<?php // $array is passed by reference function testForeach(&$array) { $array = array('a', 'b', 'c'); foreach ($array as $key => &$val) { //produces a, b as an output in PHP 5 //produces a, b, c as an output in PHP 7 var_dump($val); if ($val == 'b') { //remove 'c' from the array unset($array[2]); } } } $array = array(); testForeach($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Qa0G5
function name:  (null)
number of ops:  5
compiled vars:  !0 = $array
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E >   ASSIGN                                                       !0, <array>
   19     1        INIT_FCALL                                                   'testforeach'
          2        SEND_REF                                                     !0
          3        DO_FCALL                                          0          
          4      > RETURN                                                       1

Function testforeach:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
2 jumps found. (Code = 126) Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 11
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 11
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/Qa0G5
function name:  testForeach
number of ops:  14
compiled vars:  !0 = $array, !1 = $val, !2 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    4     0  E >   RECV                                                 !0      
    5     1        ASSIGN                                                       !0, <array>
    6     2      > FE_RESET_RW                                          $4      !0, ->12
          3    > > FE_FETCH_RW                                          ~5      $4, !1, ->12
          4    >   ASSIGN                                                       !2, ~5
    9     5        INIT_FCALL                                                   'var_dump'
          6        SEND_VAR                                                     !1
          7        DO_ICALL                                                     
   11     8        IS_EQUAL                                                     !1, 'b'
          9      > JMPZ                                                         ~8, ->11
   13    10    >   UNSET_DIM                                                    !0, 2
    6    11    > > JMP                                                          ->3
         12    >   FE_FREE                                                      $4
   16    13      > RETURN                                                       null

End of function testforeach

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
174.77 ms | 2577 KiB | 15 Q