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]; foreach($array as $key=>$value) { echo $key . ' : ' . $value; echo gettype("1"); } echo $array["1"];
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 16
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 16
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/gF4L9
function name:  (null)
number of ops:  20
compiled vars:  !0 = $object, !1 = $array, !2 = $value, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $4      'stdClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $4
    4     3        ASSIGN_OBJ                                               !0, '1'
          4        OP_DATA                                                  'one'
    6     5        CAST                                          7  ~8      !0
          6        ASSIGN                                                   !1, ~8
   19     7      > FE_RESET_R                                       $10     !1, ->16
          8    > > FE_FETCH_R                                       ~11     $10, !2, ->16
          9    >   ASSIGN                                                   !3, ~11
   20    10        CONCAT                                           ~13     !3, '+%3A+'
         11        CONCAT                                           ~14     ~13, !2
         12        ECHO                                                     ~14
   21    13        GET_TYPE                                         ~15     '1'
         14        ECHO                                                     ~15
   19    15      > JMP                                                      ->8
         16    >   FE_FREE                                                  $10
   23    17        FETCH_DIM_R                                      ~16     !1, 1
         18        ECHO                                                     ~16
         19      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.95 ms | 1393 KiB | 13 Q