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)); 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 = 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/btrIb
function name:  (null)
number of ops:  80
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                                                 
   31    53        INIT_FCALL                                               'reset'
         54        SEND_REF                                                 !0
         55        DO_ICALL                                                 
   32    56        ECHO                                                     '%0A+after+reset%3A+%0A'
   33    57        INIT_FCALL                                               'var_dump'
         58        INIT_FCALL                                               'key'
         59        SEND_VAR                                                 !0
         60        DO_ICALL                                         $22     
         61        SEND_VAR                                                 $22
         62        DO_ICALL                                                 
   35    63        INIT_FCALL                                               'end'
         64        SEND_REF                                                 !0
         65        DO_ICALL                                                 
   36    66        ECHO                                                     '%0A+after+end%3A+%0A'
   37    67        INIT_FCALL                                               'var_dump'
         68        INIT_FCALL                                               'key'
         69        SEND_VAR                                                 !0
         70        DO_ICALL                                         $25     
         71        SEND_VAR                                                 $25
         72        DO_ICALL                                                 
   39    73        ECHO                                                     '%0A+trying+to+trigger+%22Undefined+index%3A++%22+error%3A+with+NULL+key%0A'
   40    74        FETCH_DIM_R                                      ~27     !0, null
         75        FREE                                                     ~27
   42    76        ECHO                                                     '%0A+trying+to+trigger+%22Undefined+index%3A++%22+error%3A+with+empty+string+key%0A'
   43    77        FETCH_DIM_R                                      ~28     !0, ''
         78        FREE                                                     ~28
         79      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.77 ms | 1400 KiB | 21 Q