3v4l.org

run code in 300+ PHP versions simultaneously
<?php $items = array('A'=>'Apple', 'B'=>'Bee', 'C'=>'Candy'); var_dump(next($items)); // string(3) "Bee" because next() returns next element and advances pointer to next element foreach($items as $element) { echo $element,PHP_EOL; // print all of $items elements } var_dump(current($items)); // Should be 'string(3) "Bee"' because next() is called before foreach, but returns FALSE reset($items); var_dump(current($items)); // string(5) "Apple". reset() called. It should be "Apple".
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 12
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/HbVnd
function name:  (null)
number of ops:  29
compiled vars:  !0 = $items, !1 = $element
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    3     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'next'
          3        SEND_REF                                                 !0
          4        DO_ICALL                                         $3      
          5        SEND_VAR                                                 $3
          6        DO_ICALL                                                 
    4     7      > FE_RESET_R                                       $5      !0, ->12
          8    > > FE_FETCH_R                                               $5, !1, ->12
    5     9    >   ECHO                                                     !1
         10        ECHO                                                     '%0A'
    4    11      > JMP                                                      ->8
         12    >   FE_FREE                                                  $5
    7    13        INIT_FCALL                                               'var_dump'
         14        INIT_FCALL                                               'current'
         15        SEND_VAR                                                 !0
         16        DO_ICALL                                         $6      
         17        SEND_VAR                                                 $6
         18        DO_ICALL                                                 
    8    19        INIT_FCALL                                               'reset'
         20        SEND_REF                                                 !0
         21        DO_ICALL                                                 
    9    22        INIT_FCALL                                               'var_dump'
         23        INIT_FCALL                                               'current'
         24        SEND_VAR                                                 !0
         25        DO_ICALL                                         $9      
         26        SEND_VAR                                                 $9
         27        DO_ICALL                                                 
         28      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.12 ms | 1002 KiB | 17 Q