3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = json_decode('{ "list": [ { "Id": 398, "Product Title": "Banner", "Sku": "vb-13oz", "Short Description": "text", "Long Description": "text", "Cost": "0.95", "Price": "3.25", "Category": [{ "Id": 9, "Title": "Banners" }], "Attribute Sides": [{ "Id": 1, "Title": "1 Side" }], "Attribute Grommets": [ { "Id": 1, "Title": "Every 2\' All Sides" }, { "Id": 2, "Title": "Every 2\' Top and Bottom" }, { "Id": 3, "Title": "Every 2\' Left & Right" }, { "Id": 4, "Title": "4 Corners Only" }, { "Id": 5, "Title": "No Gromments" } ] } ] }', true); foreach($data['list'] as $key => $item) { $data['list'][$key]['Attribute Grommets'] = [ [ 'Id' => $item['Attribute Grommets'][0]['Id'], 'Title' => implode(' | ', array_column($item['Attribute Grommets'], 'Title')) ] ]; } echo json_encode($data, JSON_PRETTY_PRINT);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 29
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 29
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/rSHmM
function name:  (null)
number of ops:  36
compiled vars:  !0 = $data, !1 = $item, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'json_decode'
          1        SEND_VAL                                                 '%7B%0A++++%22list%22%3A+%5B%0A++++++++%7B%0A++++++++++++%22Id%22%3A+398%2C%0A++++++++++++%22Product+Title%22%3A+%22Banner%22%2C%0A++++++++++++%22Sku%22%3A+%22vb-13oz%22%2C%0A++++++++++++%22Short+Description%22%3A+%22text%22%2C%0A++++++++++++%22Long+Description%22%3A+%22text%22%2C%0A++++++++++++%22Cost%22%3A+%220.95%22%2C%0A++++++++++++%22Price%22%3A+%223.25%22%2C%0A++++++++++++%22Category%22%3A+%5B%7B+%22Id%22%3A+9%2C+%22Title%22%3A+%22Banners%22+%7D%5D%2C%0A++++++++++++%22Attribute+Sides%22%3A+%5B%7B+%22Id%22%3A+1%2C+%22Title%22%3A+%221+Side%22+%7D%5D%2C%0A++++++++++++%22Attribute+Grommets%22%3A+%5B%0A++++++++++++++++%7B+%22Id%22%3A+1%2C+%22Title%22%3A+%22Every+2%27+All+Sides%22+%7D%2C%0A++++++++++++++++%7B+%22Id%22%3A+2%2C+%22Title%22%3A+%22Every+2%27+Top+and+Bottom%22+%7D%2C%0A++++++++++++++++%7B+%22Id%22%3A+3%2C+%22Title%22%3A+%22Every+2%27+Left+%26+Right%22+%7D%2C%0A++++++++++++++++%7B+%22Id%22%3A+4%2C+%22Title%22%3A+%224+Corners+Only%22+%7D%2C%0A++++++++++++++++%7B+%22Id%22%3A+5%2C+%22Title%22%3A+%22No+Gromments%22+%7D%0A++++++++++++%5D%0A++++++++%7D%0A++++%5D%0A%7D'
   24     2        SEND_VAL                                                 <true>
    3     3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !0, $3
   26     5        FETCH_DIM_R                                      ~5      !0, 'list'
          6      > FE_RESET_R                                       $6      ~5, ->29
          7    > > FE_FETCH_R                                       ~7      $6, !1, ->29
          8    >   ASSIGN                                                   !2, ~7
   29     9        FETCH_DIM_R                                      ~12     !1, 'Attribute+Grommets'
         10        FETCH_DIM_R                                      ~13     ~12, 0
         11        FETCH_DIM_R                                      ~14     ~13, 'Id'
         12        INIT_ARRAY                                       ~15     ~14, 'Id'
   30    13        INIT_FCALL                                               'implode'
         14        SEND_VAL                                                 '+%7C+'
         15        INIT_FCALL                                               'array_column'
         16        FETCH_DIM_R                                      ~16     !1, 'Attribute+Grommets'
         17        SEND_VAL                                                 ~16
         18        SEND_VAL                                                 'Title'
         19        DO_ICALL                                         $17     
         20        SEND_VAR                                                 $17
         21        DO_ICALL                                         $18     
         22        ADD_ARRAY_ELEMENT                                ~15     $18, 'Title'
         23        INIT_ARRAY                                       ~19     ~15
   27    24        FETCH_DIM_W                                      $9      !0, 'list'
         25        FETCH_DIM_W                                      $10     $9, !2
         26        ASSIGN_DIM                                               $10, 'Attribute+Grommets'
   30    27        OP_DATA                                                  ~19
   26    28      > JMP                                                      ->7
         29    >   FE_FREE                                                  $6
   35    30        INIT_FCALL                                               'json_encode'
         31        SEND_VAR                                                 !0
         32        SEND_VAL                                                 128
         33        DO_ICALL                                         $20     
         34        ECHO                                                     $20
         35      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.97 ms | 1006 KiB | 17 Q