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]); } } 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)); 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 = 41
Branch analysis from position: 28
2 jumps found. (Code = 78) Position 1 = 29, Position 2 = 41
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 40
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
Branch analysis from position: 40
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
filename:       /in/c4f8k
function name:  (null)
number of ops:  76
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, ->41
         28    > > FE_FETCH_R                                       ~13     $12, !1, ->41
         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
   15    40    > > JMP                                                      ->28
         41    >   FE_FREE                                                  $12
   23    42        ECHO                                                     '%0A+after+loop%3A+%0A'
   24    43        INIT_FCALL                                               'var_dump'
         44        INIT_FCALL                                               'key'
         45        SEND_VAR                                                 !0
         46        DO_ICALL                                         $18     
         47        SEND_VAR                                                 $18
         48        DO_ICALL                                                 
   26    49        INIT_FCALL                                               'reset'
         50        SEND_REF                                                 !0
         51        DO_ICALL                                                 
   27    52        ECHO                                                     '%0A+after+reset%3A+%0A'
   28    53        INIT_FCALL                                               'var_dump'
         54        INIT_FCALL                                               'key'
         55        SEND_VAR                                                 !0
         56        DO_ICALL                                         $21     
         57        SEND_VAR                                                 $21
         58        DO_ICALL                                                 
   30    59        INIT_FCALL                                               'end'
         60        SEND_REF                                                 !0
         61        DO_ICALL                                                 
   31    62        ECHO                                                     '%0A+after+end%3A+%0A'
   32    63        INIT_FCALL                                               'var_dump'
         64        INIT_FCALL                                               'key'
         65        SEND_VAR                                                 !0
         66        DO_ICALL                                         $24     
         67        SEND_VAR                                                 $24
         68        DO_ICALL                                                 
   34    69        ECHO                                                     '%0A+trying+to+trigger+%22Undefined+index%3A++%22+error%3A+with+NULL+key%0A'
   35    70        FETCH_DIM_R                                      ~26     !0, null
         71        FREE                                                     ~26
   37    72        ECHO                                                     '%0A+trying+to+trigger+%22Undefined+index%3A++%22+error%3A+with+empty+string+key%0A'
   38    73        FETCH_DIM_R                                      ~27     !0, ''
         74        FREE                                                     ~27
         75      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.38 ms | 1392 KiB | 21 Q