3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $array = array(); echo PHP_EOL . ' on empty array: ' . PHP_EOL; var_dump(key($array)); $array[] = 'f'; echo PHP_EOL . ' size one array: ' . PHP_EOL; var_dump(key($array)); $array[] = 'f'; echo PHP_EOL . ' size two array: ' . PHP_EOL; var_dump(key($array)); echo PHP_EOL . ' within loop: ' . PHP_EOL; foreach ($array as $item) { var_dump(key($array)); } echo PHP_EOL . ' after loop: ' . PHP_EOL; var_dump(key($array)); reset($array); echo PHP_EOL . ' after reset: ' . PHP_EOL; var_dump(key($array)); end($array); echo PHP_EOL . ' after end: ' . PHP_EOL; var_dump(key($array));
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = 28, Position 2 = 36
Branch analysis from position: 28
Jump found. Position 1 = 29, Position 2 = 36
Branch analysis from position: 29
Jump found. Position 1 = 28
Branch analysis from position: 28
Branch analysis from position: 36
Jump found. Position 1 = -2
Branch analysis from position: 36
filename:       /in/sLUNt
function name:  (null)
number of ops:  65
compiled vars:  !0 = $array, !1 = $item
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   2     0  E >   ASSIGN                                                   !0, <array>
   3     1        ECHO                                                     '%0A+on+empty+array%3A+%0A'
   4     2        INIT_FCALL                                               'var_dump'
         3        INIT_FCALL                                               'key'
         4        SEND_VAR                                                 !0
         5        DO_ICALL                                         $3      
         6        SEND_VAR                                                 $3
         7        DO_ICALL                                                 
   6     8        ASSIGN_DIM                                               !0
         9        OP_DATA                                                  'f'
   7    10        ECHO                                                     '%0A+size+one+array%3A+%0A'
   8    11        INIT_FCALL                                               'var_dump'
        12        INIT_FCALL                                               'key'
        13        SEND_VAR                                                 !0
        14        DO_ICALL                                         $6      
        15        SEND_VAR                                                 $6
        16        DO_ICALL                                                 
  10    17        ASSIGN_DIM                                               !0
        18        OP_DATA                                                  'f'
  11    19        ECHO                                                     '%0A+size+two+array%3A+%0A'
  12    20        INIT_FCALL                                               'var_dump'
        21        INIT_FCALL                                               'key'
        22        SEND_VAR                                                 !0
        23        DO_ICALL                                         $9      
        24        SEND_VAR                                                 $9
        25        DO_ICALL                                                 
  14    26        ECHO                                                     '%0A+within+loop%3A+%0A'
  15    27      > FE_RESET_R                                       $11     !0, ->36
        28    > > FE_FETCH_R                                               $11, !1, ->36
  16    29    >   INIT_FCALL                                               'var_dump'
        30        INIT_FCALL                                               'key'
        31        SEND_VAR                                                 !0
        32        DO_ICALL                                         $12     
        33        SEND_VAR                                                 $12
        34        DO_ICALL                                                 
        35      > JMP                                                      ->28
        36    >   FE_FREE                                                  $11
  19    37        ECHO                                                     '%0A+after+loop%3A+%0A'
  20    38        INIT_FCALL                                               'var_dump'
        39        INIT_FCALL                                               'key'
        40        SEND_VAR                                                 !0
        41        DO_ICALL                                         $14     
        42        SEND_VAR                                                 $14
        43        DO_ICALL                                                 
  22    44        INIT_FCALL                                               'reset'
        45        SEND_REF                                                 !0
        46        DO_ICALL                                                 
  23    47        ECHO                                                     '%0A+after+reset%3A+%0A'
  24    48        INIT_FCALL                                               'var_dump'
        49        INIT_FCALL                                               'key'
        50        SEND_VAR                                                 !0
        51        DO_ICALL                                         $17     
        52        SEND_VAR                                                 $17
        53        DO_ICALL                                                 
  26    54        INIT_FCALL                                               'end'
        55        SEND_REF                                                 !0
        56        DO_ICALL                                                 
  27    57        ECHO                                                     '%0A+after+end%3A+%0A'
  28    58        INIT_FCALL                                               'var_dump'
        59        INIT_FCALL                                               'key'
        60        SEND_VAR                                                 !0
        61        DO_ICALL                                         $20     
        62        SEND_VAR                                                 $20
        63        DO_ICALL                                                 
        64      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 7.2.0