3v4l.org

run code in 300+ PHP versions simultaneously
<?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 $key => $value) { var_dump(key($array)); if ($key == 0) { echo PHP_EOL . ' unsetting first element.... ' . PHP_EOL; unset($array[$key]); } if ($key == 1) { echo PHP_EOL . ' unsetting second element.... ' . PHP_EOL; unset($array[$key]); } } echo PHP_EOL . ' after loop: ' . PHP_EOL; var_dump(key($array)); var_dump(current($array)); reset($array); echo PHP_EOL . ' after reset: ' . PHP_EOL; var_dump(key($array)); var_dump(current($array)); end($array); echo PHP_EOL . ' after end: ' . PHP_EOL; var_dump(key($array)); var_dump(current($array)); echo PHP_EOL . ' trying to trigger "Undefined index: " error: with NULL key' . PHP_EOL; $array[null]; echo PHP_EOL . ' trying to trigger "Undefined index: " error: with empty string key' . PHP_EOL; $array[''];
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 28, Position 2 = 45
Branch analysis from position: 28
2 jumps found. (Code = 78) Position 1 = 29, Position 2 = 45
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 40
Branch analysis from position: 38
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 44
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
Branch analysis from position: 44
Branch analysis from position: 40
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 45
filename:       /in/g5CL7
function name:  (null)
number of ops:  98
compiled vars:  !0 = $array, !1 = $value, !2 = $key
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                                         $4      
          6        SEND_VAR                                                 $4
          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                                         $7      
         15        SEND_VAR                                                 $7
         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                                         $10     
         24        SEND_VAR                                                 $10
         25        DO_ICALL                                                 
   14    26        ECHO                                                     '%0A+within+loop%3A+%0A'
   15    27      > FE_RESET_R                                       $12     !0, ->45
         28    > > FE_FETCH_R                                       ~13     $12, !1, ->45
         29    >   ASSIGN                                                   !2, ~13
   16    30        INIT_FCALL                                               'var_dump'
         31        INIT_FCALL                                               'key'
         32        SEND_VAR                                                 !0
         33        DO_ICALL                                         $15     
         34        SEND_VAR                                                 $15
         35        DO_ICALL                                                 
   17    36        IS_EQUAL                                                 !2, 0
         37      > JMPZ                                                     ~17, ->40
   18    38    >   ECHO                                                     '%0A+unsetting+first+element....+%0A'
   19    39        UNSET_DIM                                                !0, !2
   22    40    >   IS_EQUAL                                                 !2, 1
         41      > JMPZ                                                     ~18, ->44
   23    42    >   ECHO                                                     '%0A+unsetting+second+element....+%0A'
   24    43        UNSET_DIM                                                !0, !2
   15    44    > > JMP                                                      ->28
         45    >   FE_FREE                                                  $12
   28    46        ECHO                                                     '%0A+after+loop%3A+%0A'
   29    47        INIT_FCALL                                               'var_dump'
         48        INIT_FCALL                                               'key'
         49        SEND_VAR                                                 !0
         50        DO_ICALL                                         $19     
         51        SEND_VAR                                                 $19
         52        DO_ICALL                                                 
   30    53        INIT_FCALL                                               'var_dump'
         54        INIT_FCALL                                               'current'
         55        SEND_VAR                                                 !0
         56        DO_ICALL                                         $21     
         57        SEND_VAR                                                 $21
         58        DO_ICALL                                                 
   32    59        INIT_FCALL                                               'reset'
         60        SEND_REF                                                 !0
         61        DO_ICALL                                                 
   33    62        ECHO                                                     '%0A+after+reset%3A+%0A'
   34    63        INIT_FCALL                                               'var_dump'
         64        INIT_FCALL                                               'key'
         65        SEND_VAR                                                 !0
         66        DO_ICALL                                         $24     
         67        SEND_VAR                                                 $24
         68        DO_ICALL                                                 
   35    69        INIT_FCALL                                               'var_dump'
         70        INIT_FCALL                                               'current'
         71        SEND_VAR                                                 !0
         72        DO_ICALL                                         $26     
         73        SEND_VAR                                                 $26
         74        DO_ICALL                                                 
   37    75        INIT_FCALL                                               'end'
         76        SEND_REF                                                 !0
         77        DO_ICALL                                                 
   38    78        ECHO                                                     '%0A+after+end%3A+%0A'
   39    79        INIT_FCALL                                               'var_dump'
         80        INIT_FCALL                                               'key'
         81        SEND_VAR                                                 !0
         82        DO_ICALL                                         $29     
         83        SEND_VAR                                                 $29
         84        DO_ICALL                                                 
   40    85        INIT_FCALL                                               'var_dump'
         86        INIT_FCALL                                               'current'
         87        SEND_VAR                                                 !0
         88        DO_ICALL                                         $31     
         89        SEND_VAR                                                 $31
         90        DO_ICALL                                                 
   42    91        ECHO                                                     '%0A+trying+to+trigger+%22Undefined+index%3A++%22+error%3A+with+NULL+key%0A'
   43    92        FETCH_DIM_R                                      ~33     !0, null
         93        FREE                                                     ~33
   45    94        ECHO                                                     '%0A+trying+to+trigger+%22Undefined+index%3A++%22+error%3A+with+empty+string+key%0A'
   46    95        FETCH_DIM_R                                      ~34     !0, ''
         96        FREE                                                     ~34
         97      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.78 ms | 1409 KiB | 23 Q