3v4l.org

run code in 500+ 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 reset($items); // Reset mid-loop! } 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 = 15
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 15
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/KTCrI
function name:  (null)
number of ops:  32
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, ->15
          8    > > FE_FETCH_R                                                   $5, !1, ->15
    5     9    >   ECHO                                                         !1
         10        ECHO                                                         '%0A'
    6    11        INIT_FCALL                                                   'reset'
         12        SEND_REF                                                     !0
         13        DO_ICALL                                                     
    4    14      > JMP                                                          ->8
         15    >   FE_FREE                                                      $5
    8    16        INIT_FCALL                                                   'var_dump'
         17        INIT_FCALL                                                   'current'
         18        SEND_VAR                                                     !0
         19        DO_ICALL                                             $7      
         20        SEND_VAR                                                     $7
         21        DO_ICALL                                                     
    9    22        INIT_FCALL                                                   'reset'
         23        SEND_REF                                                     !0
         24        DO_ICALL                                                     
   10    25        INIT_FCALL                                                   'var_dump'
         26        INIT_FCALL                                                   'current'
         27        SEND_VAR                                                     !0
         28        DO_ICALL                                             $10     
         29        SEND_VAR                                                     $10
         30        DO_ICALL                                                     
         31      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
168.07 ms | 2707 KiB | 17 Q