3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 8 => [ 2 => [ 'num_rooms' => 2, 'adults' => [1, 1], 'children' => [0, 0], 'prices' => [50, 50], 'price' => 130, 'supp' => 30, ], 3 => [ 'num_rooms' => 1, 'adults' => [1], 'prices' => [100], 'price' => 150, 'supp' => 50, ], ], 1 => [ 2 => [ 'num_rooms' => 2, 'adults' => [1, 1], 'children' => [1, 0], 'prices' => [75, 75], 'price' => 170, 'supp' => 20, ], ], ]; $result = []; foreach (array_merge(...$array) as $row) { foreach ($row as $k => $v) { $result[$k] = ($result[$k] ?? 0) + array_sum((array) $v); } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 24
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 24
Branch analysis from position: 8
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 22
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 22
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 22
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/9gCH1
function name:  (null)
number of ops:  29
compiled vars:  !0 = $array, !1 = $result, !2 = $row, !3 = $v, !4 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   34     1        ASSIGN                                                   !1, <array>
   35     2        INIT_FCALL                                               'array_merge'
          3        SEND_UNPACK                                              !0
          4        CHECK_UNDEF_ARGS                                         
          5        DO_ICALL                                         $7      
          6      > FE_RESET_R                                       $8      $7, ->24
          7    > > FE_FETCH_R                                               $8, !2, ->24
   36     8    > > FE_RESET_R                                       $9      !2, ->22
          9    > > FE_FETCH_R                                       ~10     $9, !3, ->22
         10    >   ASSIGN                                                   !4, ~10
   37    11        FETCH_DIM_IS                                     ~13     !1, !4
         12        COALESCE                                         ~14     ~13
         13        QM_ASSIGN                                        ~14     0
         14        INIT_FCALL                                               'array_sum'
         15        CAST                                          7  ~15     !3
         16        SEND_VAL                                                 ~15
         17        DO_ICALL                                         $16     
         18        ADD                                              ~17     ~14, $16
         19        ASSIGN_DIM                                               !1, !4
         20        OP_DATA                                                  ~17
   36    21      > JMP                                                      ->9
         22    >   FE_FREE                                                  $9
   35    23      > JMP                                                      ->7
         24    >   FE_FREE                                                  $8
   40    25        INIT_FCALL                                               'var_export'
         26        SEND_VAR                                                 !1
         27        DO_ICALL                                                 
         28      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.79 ms | 1003 KiB | 16 Q