3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array1 = [ "2018" => [ "JAN" => 100, "FEB" => 200, "MAR" => 300, "APR" => 400 ] ]; $array2 = [ "2018" => [ "FEB" => 200, "MAR" => 300, "APR" => 400, "MAY" => 200, ] ]; $array3 = [ "2018" => [ "MAY" => 200, "JUN" => 100, "JUL" => 300, "AUG" => 400, ] ]; $new = array_merge_recursive([$array1], [$array2], [$array3]); foreach($new as $arr){ foreach($arr as $year => $sub){ foreach($sub as $month => $val){ if(!isset($res[$year][$month])) $res[$year][$month] =0; $res[$year][$month] += $val; } } } var_dump($res);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 35
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 35
Branch analysis from position: 14
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 33
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 33
Branch analysis from position: 16
2 jumps found. (Code = 77) Position 1 = 18, Position 2 = 31
Branch analysis from position: 18
2 jumps found. (Code = 78) Position 1 = 19, Position 2 = 31
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 27
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 27
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 31
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 33
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
filename:       /in/WHdDJi
function name:  (null)
number of ops:  40
compiled vars:  !0 = $array1, !1 = $array2, !2 = $array3, !3 = $new, !4 = $arr, !5 = $sub, !6 = $year, !7 = $val, !8 = $month, !9 = $res
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   13     1        ASSIGN                                                       !1, <array>
   23     2        ASSIGN                                                       !2, <array>
   33     3        INIT_FCALL                                                   'array_merge_recursive'
          4        INIT_ARRAY                                           ~13     !0
          5        SEND_VAL                                                     ~13
          6        INIT_ARRAY                                           ~14     !1
          7        SEND_VAL                                                     ~14
          8        INIT_ARRAY                                           ~15     !2
          9        SEND_VAL                                                     ~15
         10        DO_ICALL                                             $16     
         11        ASSIGN                                                       !3, $16
   34    12      > FE_RESET_R                                           $18     !3, ->35
         13    > > FE_FETCH_R                                                   $18, !4, ->35
   35    14    > > FE_RESET_R                                           $19     !4, ->33
         15    > > FE_FETCH_R                                           ~20     $19, !5, ->33
         16    >   ASSIGN                                                       !6, ~20
   36    17      > FE_RESET_R                                           $22     !5, ->31
         18    > > FE_FETCH_R                                           ~23     $22, !7, ->31
         19    >   ASSIGN                                                       !8, ~23
   37    20        FETCH_DIM_IS                                         ~25     !9, !6
         21        ISSET_ISEMPTY_DIM_OBJ                             0  ~26     ~25, !8
         22        BOOL_NOT                                             ~27     ~26
         23      > JMPZ                                                         ~27, ->27
         24    >   FETCH_DIM_W                                          $28     !9, !6
         25        ASSIGN_DIM                                                   $28, !8
         26        OP_DATA                                                      0
   38    27    >   FETCH_DIM_RW                                         $30     !9, !6
         28        ASSIGN_DIM_OP                    +=               1          $30, !8
         29        OP_DATA                                                      !7
   36    30      > JMP                                                          ->18
         31    >   FE_FREE                                                      $22
   35    32      > JMP                                                          ->15
         33    >   FE_FREE                                                      $19
   34    34      > JMP                                                          ->13
         35    >   FE_FREE                                                      $18
   42    36        INIT_FCALL                                                   'var_dump'
         37        SEND_VAR                                                     !9
         38        DO_ICALL                                                     
         39      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
161.94 ms | 2155 KiB | 15 Q