3v4l.org

run code in 500+ PHP versions simultaneously
<?php // Test for switch not running default code when array element key is 0 if there is a mix of array keys that are numerical along with a string array key $test = array(0 => "First element, should be 0",1 => "Second element, should be 1",2 => "Third element, should be 2","Three" => "Fourth element, should be Three"); print_r($test); foreach($test as $k => $v) { switch($k) { case "Three": echo "not to be printed\n"; break; default: echo $k.": ".$v."\n"; break; } } ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 19
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 19
Branch analysis from position: 6
3 jumps found. (Code = 188) Position 1 = 11, Position 2 = 13, Position 3 = 8
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 11
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 11
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/mU9Fr
function name:  (null)
number of ops:  21
compiled vars:  !0 = $test, !1 = $v, !2 = $k
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   ASSIGN                                                       !0, <array>
    7     1        INIT_FCALL                                                   'print_r'
          2        SEND_VAR                                                     !0
          3        DO_ICALL                                                     
    9     4      > FE_RESET_R                                           $5      !0, ->19
          5    > > FE_FETCH_R                                           ~6      $5, !1, ->19
          6    >   ASSIGN                                                       !2, ~6
   10     7      > SWITCH_STRING                                                !2, [ 'Three':->11, ], ->13
   11     8    >   IS_EQUAL                                                     !2, 'Three'
          9      > JMPNZ                                                        ~8, ->11
         10    > > JMP                                                          ->13
   12    11    >   ECHO                                                         'not+to+be+printed%0A'
   13    12      > JMP                                                          ->18
   15    13    >   CONCAT                                               ~9      !2, '%3A+'
         14        CONCAT                                               ~10     ~9, !1
         15        CONCAT                                               ~11     ~10, '%0A'
         16        ECHO                                                         ~11
   16    17      > JMP                                                          ->18
    9    18    > > JMP                                                          ->5
         19    >   FE_FREE                                                      $5
   20    20      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
124.84 ms | 478 KiB | 8 Q