3v4l.org

run code in 300+ PHP versions simultaneously
<?php $son = '{ "1":{ "id":"1", "name":"jack" }, "2":{ "id":"2", "name":"john" } }'; $json = json_decode($son); //var_dump($json); var_dump($json->{'1'}); // correct result $index = 1; var_dump($json->$index); // correct result
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZARaP
function name:  (null)
number of ops:  15
compiled vars:  !0 = $son, !1 = $json, !2 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%7B%0A%221%22%3A%7B+%22id%22%3A%221%22%2C+%22name%22%3A%22jack%22+%7D%2C%0A%222%22%3A%7B+%22id%22%3A%222%22%2C+%22name%22%3A%22john%22+%7D%0A%7D'
    8     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $4      
          4        ASSIGN                                                   !1, $4
   10     5        INIT_FCALL                                               'var_dump'
          6        FETCH_OBJ_R                                      ~6      !1, '1'
          7        SEND_VAL                                                 ~6
          8        DO_ICALL                                                 
   11     9        ASSIGN                                                   !2, 1
   12    10        INIT_FCALL                                               'var_dump'
         11        FETCH_OBJ_R                                      ~9      !1, !2
         12        SEND_VAL                                                 ~9
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.75 ms | 1394 KiB | 17 Q