3v4l.org

run code in 300+ PHP versions simultaneously
<?php $jsonStr = '{"return_data": { "friend_info": [ { "desc": "name", "value": "Ken" }, { "desc": "profile_pic", "value": "http://aaa.caa/1234569/picture?type=large" } ] }}'; $json = json_decode($jsonStr, true); $obj = new stdClass; foreach ($json["return_data"]["friend_info"] as $item) $obj->{$item["desc"]} = $item["value"]; $json["return_data"]["friend_info"] = $obj; $jsonStr = json_encode($json); echo $jsonStr;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 18
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 18
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/l7qdZ
function name:  (null)
number of ops:  28
compiled vars:  !0 = $jsonStr, !1 = $json, !2 = $obj, !3 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%7B%22return_data%22%3A+%7B%0A++++%22friend_info%22%3A+%5B%0A++++++++++++%7B%0A++++++++++++++++%22desc%22%3A+%22name%22%2C%0A++++++++++++++++%22value%22%3A+%22Ken%22%0A++++++++++++%7D%2C%0A++++++++++++%7B%0A++++++++++++++++%22desc%22%3A+%22profile_pic%22%2C%0A++++++++++++++++%22value%22%3A+%22http%3A%2F%2Faaa.caa%2F1234569%2Fpicture%3Ftype%3Dlarge%22%0A++++++++++++%7D%0A+++++%5D%0A%7D%7D'
   15     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !1, $5
   16     6        NEW                                              $7      'stdClass'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !2, $7
   17     9        FETCH_DIM_R                                      ~10     !1, 'return_data'
         10        FETCH_DIM_R                                      ~11     ~10, 'friend_info'
         11      > FE_RESET_R                                       $12     ~11, ->18
         12    > > FE_FETCH_R                                               $12, !3, ->18
   18    13    >   FETCH_DIM_R                                      ~13     !3, 'desc'
         14        FETCH_DIM_R                                      ~15     !3, 'value'
         15        ASSIGN_OBJ                                               !2, ~13
         16        OP_DATA                                                  ~15
   17    17      > JMP                                                      ->12
         18    >   FE_FREE                                                  $12
   20    19        FETCH_DIM_W                                      $16     !1, 'return_data'
         20        ASSIGN_DIM                                               $16, 'friend_info'
         21        OP_DATA                                                  !2
   21    22        INIT_FCALL                                               'json_encode'
         23        SEND_VAR                                                 !1
         24        DO_ICALL                                         $18     
         25        ASSIGN                                                   !0, $18
   23    26        ECHO                                                     !0
   24    27      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.58 ms | 1439 KiB | 15 Q