3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = [ 'Orders' => [ [ 'transaction_id' => '78078', 'date' => 1616277653, 'currency' => 'EUR', 'items' => [ ['title' => 'Title 1', 'quantity' => 200, 'price' => 2.1, 'sku' => '1T.810BK'], ['title' => 'Title 2', 'quantity' => 250, 'price' => 1.78, 'sku' => '1090.005BK'], ], ], [ 'transaction_id' => 78079, 'date' => 1616597838, 'currency' => 'EUR', 'items' => [ ['title' => 'title 3', 'quantity' => 3, 'price' => 118.3, 'sku' => '1.DIYBOX.ULT.638RE'], ], ], [ 'transaction_id' => 78080, 'date' => 1616598322, 'currency' => 'EUR', 'items' => [ ['title' => 'title 2', 'quantity' => 300, 'price' => 1.78, 'sku' => '1090.005BK'], ], ] ] ]; $result = []; foreach ($data['Orders'] as $order) { foreach ($order['items'] as $item) { $result[$item['sku']] = ($result[$item['sku']] ?? 0) + $item['quantity']; } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 20
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 20
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 18
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 18
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 18
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/Br3iV
function name:  (null)
number of ops:  25
compiled vars:  !0 = $data, !1 = $result, !2 = $order, !3 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   33     1        ASSIGN                                                   !1, <array>
   34     2        FETCH_DIM_R                                      ~6      !0, 'Orders'
          3      > FE_RESET_R                                       $7      ~6, ->20
          4    > > FE_FETCH_R                                               $7, !2, ->20
   35     5    >   FETCH_DIM_R                                      ~8      !2, 'items'
          6      > FE_RESET_R                                       $9      ~8, ->18
          7    > > FE_FETCH_R                                               $9, !3, ->18
   36     8    >   FETCH_DIM_R                                      ~10     !3, 'sku'
          9        FETCH_DIM_R                                      ~12     !3, 'sku'
         10        FETCH_DIM_IS                                     ~13     !1, ~12
         11        COALESCE                                         ~14     ~13
         12        QM_ASSIGN                                        ~14     0
         13        FETCH_DIM_R                                      ~15     !3, 'quantity'
         14        ADD                                              ~16     ~14, ~15
         15        ASSIGN_DIM                                               !1, ~10
         16        OP_DATA                                                  ~16
   35    17      > JMP                                                      ->7
         18    >   FE_FREE                                                  $9
   34    19      > JMP                                                      ->4
         20    >   FE_FREE                                                  $7
   39    21        INIT_FCALL                                               'var_export'
         22        SEND_VAR                                                 !1
         23        DO_ICALL                                                 
         24      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.25 ms | 1003 KiB | 14 Q