3v4l.org

run code in 500+ PHP versions simultaneously
<?php $json = <<<EOT { "data": [ { "product_id": "123456", "item": "ZAD", "time": "15:30", "quantity": 1 }, { "product_id": "24534", "item": "REST", "time": "5:30", "quantity": 1 }, { "product_id": "123456", "item": "RAD", "time": "10:30", "quantity": 2 } ] } EOT; $d_data = json_decode($json, true); $f_data = $d_data['data']; $result = []; foreach($f_data as $data) { $result[$data['product_id']][$data['item']] = [ $data['time'], $data['quantity'] ]; } print_r($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 21
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 21
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/sf7om
function name:  (null)
number of ops:  26
compiled vars:  !0 = $json, !1 = $d_data, !2 = $f_data, !3 = $result, !4 = $data
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%7B%0A%22data%22%3A+%5B%0A++++%7B%0A++++++%22product_id%22%3A+%22123456%22%2C%0A++++++%22item%22%3A+%22ZAD%22%2C%0A++++++%22time%22%3A+%2215%3A30%22%2C%0A++++++%22quantity%22%3A+1%0A++++%7D%2C%0A++++%7B%0A++++++%22product_id%22%3A+%2224534%22%2C%0A++++++%22item%22%3A+%22REST%22%2C%0A++++++%22time%22%3A+%225%3A30%22%2C%0A++++++%22quantity%22%3A+1%0A++++%7D%2C%0A++++%7B%0A++++++%22product_id%22%3A+%22123456%22%2C%0A++++++%22item%22%3A+%22RAD%22%2C%0A++++++%22time%22%3A+%2210%3A30%22%2C%0A++++++%22quantity%22%3A+2%0A++++%7D%0A%5D%0A%7D'
   28     1        INIT_FCALL                                                   'json_decode'
          2        SEND_VAR                                                     !0
          3        SEND_VAL                                                     <true>
          4        DO_ICALL                                             $6      
          5        ASSIGN                                                       !1, $6
   30     6        FETCH_DIM_R                                          ~8      !1, 'data'
          7        ASSIGN                                                       !2, ~8
   32     8        ASSIGN                                                       !3, <array>
   33     9      > FE_RESET_R                                           $11     !2, ->21
         10    > > FE_FETCH_R                                                   $11, !4, ->21
   34    11    >   FETCH_DIM_R                                          ~12     !4, 'product_id'
         12        FETCH_DIM_R                                          ~14     !4, 'item'
   35    13        FETCH_DIM_R                                          ~16     !4, 'time'
         14        INIT_ARRAY                                           ~17     ~16
   36    15        FETCH_DIM_R                                          ~18     !4, 'quantity'
         16        ADD_ARRAY_ELEMENT                                    ~17     ~18
   34    17        FETCH_DIM_W                                          $13     !3, ~12
         18        ASSIGN_DIM                                                   $13, ~14
   36    19        OP_DATA                                                      ~17
   33    20      > JMP                                                          ->10
         21    >   FE_FREE                                                      $11
   40    22        INIT_FCALL                                                   'print_r'
         23        SEND_VAR                                                     !3
         24        DO_ICALL                                                     
         25      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
178.64 ms | 1963 KiB | 15 Q