3v4l.org

run code in 300+ PHP versions simultaneously
<?php $consumption = [ 'MONDAY' => [ 'REFRIGERATOR' => [ 3, 9, 7, ], 'WASHINGMACHINE' => [ 2, 4, 2, 8, ], ], 'TUESDAY' => [ 'REFRIGERATOR' => [ 5, 3, 8, ], 'OVEN' => [ 4, 1, 4, ], ], 'WEDNESDAY' => [ 'TV' => [ 6, 9, ], 'REFRIGERATOR' => [ 2, 3, 5, 2, ], ], 'THURSDAY' => [ 'TV' => [ 5, 3, 3, 2, ], 'FAN' => [ 4, 9, 8, 5, ], ], 'FRIDAY' => [ 'WASHINGMACHINE' => [ 8, 5, ], 'OVEN' => [ 3, 9, 7, ], ], ]; $result = []; foreach($consumption as $v) { foreach($v as $v_k => $v_v) { if(isset($result[$v_k])) $result[$v_k] += array_sum($v_v); else $result[$v_k] = array_sum($v_v); } } print_r($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 23
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 23
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 21
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 21
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 15
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 21
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/o4R8u
function name:  (null)
number of ops:  28
compiled vars:  !0 = $consumption, !1 = $result, !2 = $v, !3 = $v_v, !4 = $v_k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   67     1        ASSIGN                                                   !1, <array>
   68     2      > FE_RESET_R                                       $7      !0, ->23
          3    > > FE_FETCH_R                                               $7, !2, ->23
   70     4    > > FE_RESET_R                                       $8      !2, ->21
          5    > > FE_FETCH_R                                       ~9      $8, !3, ->21
          6    >   ASSIGN                                                   !4, ~9
   72     7        ISSET_ISEMPTY_DIM_OBJ                         0          !1, !4
          8      > JMPZ                                                     ~11, ->15
   73     9    >   INIT_FCALL                                               'array_sum'
         10        SEND_VAR                                                 !3
         11        DO_ICALL                                         $13     
         12        ASSIGN_DIM_OP                +=               1          !1, !4
         13        OP_DATA                                                  $13
         14      > JMP                                                      ->20
   75    15    >   INIT_FCALL                                               'array_sum'
         16        SEND_VAR                                                 !3
         17        DO_ICALL                                         $15     
         18        ASSIGN_DIM                                               !1, !4
         19        OP_DATA                                                  $15
   70    20    > > JMP                                                      ->5
         21    >   FE_FREE                                                  $8
   68    22      > JMP                                                      ->3
         23    >   FE_FREE                                                  $7
   79    24        INIT_FCALL                                               'print_r'
         25        SEND_VAR                                                 !1
         26        DO_ICALL                                                 
         27      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.14 ms | 1409 KiB | 17 Q