3v4l.org

run code in 500+ PHP versions simultaneously
<?php $json = '{"lenght":0,"subcategory":[]}'; $last_id = 123; $obj = json_decode($json, true); array_push($obj["subcategory"], $last_id); $obj["lenght"] = (int)$obj["lenght"] + 1; $json = json_encode($obj); echo $json;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GGKPr
function name:  (null)
number of ops:  23
compiled vars:  !0 = $json, !1 = $last_id, !2 = $obj
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%7B%22lenght%22%3A0%2C%22subcategory%22%3A%5B%5D%7D'
    4     1        ASSIGN                                                       !1, 123
    6     2        INIT_FCALL                                                   'json_decode'
          3        SEND_VAR                                                     !0
          4        SEND_VAL                                                     <true>
          5        DO_ICALL                                             $5      
          6        ASSIGN                                                       !2, $5
    7     7        INIT_FCALL                                                   'array_push'
          8        FETCH_DIM_W                                          $7      !2, 'subcategory'
          9        SEND_REF                                                     $7
         10        SEND_VAR                                                     !1
         11        DO_ICALL                                                     
    8    12        FETCH_DIM_R                                          ~10     !2, 'lenght'
         13        CAST                                              4  ~11     ~10
         14        ADD                                                  ~12     ~11, 1
         15        ASSIGN_DIM                                                   !2, 'lenght'
         16        OP_DATA                                                      ~12
   10    17        INIT_FCALL                                                   'json_encode'
         18        SEND_VAR                                                     !2
         19        DO_ICALL                                             $13     
         20        ASSIGN                                                       !0, $13
   11    21        ECHO                                                         !0
   12    22      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
158.55 ms | 1992 KiB | 15 Q