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'], ], ] ] ]; var_export( array_reduce( array_merge( ...array_column($data['Orders'], 'items') ), function($carry, $item) { $carry[$item['sku']] = ($carry[$item['sku']] ?? 0) + $item['quantity']; return $carry; } ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/W1fLS
function name:  (null)
number of ops:  19
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   33     1        INIT_FCALL                                               'var_export'
   34     2        INIT_FCALL                                               'array_reduce'
   35     3        INIT_FCALL                                               'array_merge'
   36     4        INIT_FCALL                                               'array_column'
          5        FETCH_DIM_R                                      ~2      !0, 'Orders'
          6        SEND_VAL                                                 ~2
          7        SEND_VAL                                                 'items'
          8        DO_ICALL                                         $3      
          9        SEND_UNPACK                                              $3
         10        CHECK_UNDEF_ARGS                                         
   35    11        DO_ICALL                                         $4      
   36    12        SEND_VAR                                                 $4
   38    13        DECLARE_LAMBDA_FUNCTION                          ~5      [0]
   41    14        SEND_VAL                                                 ~5
   34    15        DO_ICALL                                         $6      
   41    16        SEND_VAR                                                 $6
   33    17        DO_ICALL                                                 
   43    18      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/W1fLS
function name:  {closure}
number of ops:  13
compiled vars:  !0 = $carry, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   39     2        FETCH_DIM_R                                      ~2      !1, 'sku'
          3        FETCH_DIM_R                                      ~4      !1, 'sku'
          4        FETCH_DIM_IS                                     ~5      !0, ~4
          5        COALESCE                                         ~6      ~5
          6        QM_ASSIGN                                        ~6      0
          7        FETCH_DIM_R                                      ~7      !1, 'quantity'
          8        ADD                                              ~8      ~6, ~7
          9        ASSIGN_DIM                                               !0, ~2
         10        OP_DATA                                                  ~8
   40    11      > RETURN                                                   !0
   41    12*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.57 ms | 1079 KiB | 17 Q