3v4l.org

run code in 300+ PHP versions simultaneously
<?php $jsonArray = '[{"Level":"77.2023%","Product":"Milk","Temperature":"4"}, {"Level":"399.2023%","Product":"Coffee","Temperature":"34"}, {"Level":"109.2023%","Product":"Chocolate","Temperature":"14"}]'; $output = array(); foreach (json_decode($jsonArray, true) as $row) { $product = $row['Product']; $output[$product] = $row; unset($output[$product]['Product']); } echo json_encode($output) . "\n";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 15
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 15
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/sBmsr
function name:  (null)
number of ops:  22
compiled vars:  !0 = $jsonArray, !1 = $output, !2 = $row, !3 = $product
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%5B%7B%22Level%22%3A%2277.2023%25%22%2C%22Product%22%3A%22Milk%22%2C%22Temperature%22%3A%224%22%7D%2C%0A+++++++++%7B%22Level%22%3A%22399.2023%25%22%2C%22Product%22%3A%22Coffee%22%2C%22Temperature%22%3A%2234%22%7D%2C%0A+++++++++%7B%22Level%22%3A%22109.2023%25%22%2C%22Product%22%3A%22Chocolate%22%2C%22Temperature%22%3A%2214%22%7D%5D'
    5     1        ASSIGN                                                   !1, <array>
    6     2        INIT_FCALL                                               'json_decode'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 <true>
          5        DO_ICALL                                         $6      
          6      > FE_RESET_R                                       $7      $6, ->15
          7    > > FE_FETCH_R                                               $7, !2, ->15
    7     8    >   FETCH_DIM_R                                      ~8      !2, 'Product'
          9        ASSIGN                                                   !3, ~8
    8    10        ASSIGN_DIM                                               !1, !3
         11        OP_DATA                                                  !2
    9    12        FETCH_DIM_UNSET                                  $11     !1, !3
         13        UNSET_DIM                                                $11, 'Product'
    6    14      > JMP                                                      ->7
         15    >   FE_FREE                                                  $7
   11    16        INIT_FCALL                                               'json_encode'
         17        SEND_VAR                                                 !1
         18        DO_ICALL                                         $12     
         19        CONCAT                                           ~13     $12, '%0A'
         20        ECHO                                                     ~13
         21      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.88 ms | 1001 KiB | 15 Q