3v4l.org

run code in 300+ PHP versions simultaneously
<?php $object = new stdClass(); $object->{'1'} = 'one'; $array = (array) $object; var_dump($array); /* produces array(1) { ["1"]=> string(3) "one" } */ //none of the following will work $key = '1'; echo $array[1], $array['1'], $array["1"], $array[(string)1], $array[$key];
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Di79o
function name:  (null)
number of ops:  23
compiled vars:  !0 = $object, !1 = $array, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $3      'stdClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
    4     3        ASSIGN_OBJ                                               !0, '1'
          4        OP_DATA                                                  'one'
    6     5        CAST                                          7  ~7      !0
          6        ASSIGN                                                   !1, ~7
    8     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                                 
   17    10        ASSIGN                                                   !2, '1'
   18    11        FETCH_DIM_R                                      ~11     !1, 1
         12        ECHO                                                     ~11
         13        FETCH_DIM_R                                      ~12     !1, 1
         14        ECHO                                                     ~12
         15        FETCH_DIM_R                                      ~13     !1, 1
         16        ECHO                                                     ~13
         17        CAST                                          6  ~14     1
         18        FETCH_DIM_R                                      ~15     !1, ~14
         19        ECHO                                                     ~15
         20        FETCH_DIM_R                                      ~16     !1, !2
         21        ECHO                                                     ~16
         22      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.22 ms | 1395 KiB | 15 Q