3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr1 = [ "Friday" => ["Breakfast" => 32, "Lunch" => 45], "Sunday" => ["Lunch" => 12] ]; $arr2 = [ "Sunday" => ["Breakfast" => 7, "Lunch" => 3], "Monday" => ["Breakfast" => 12] ]; $arr3 = [ "Monday" => ["Breakfast" => 31] ]; $result = []; foreach (array_merge([$arr1], [$arr2], [$arr3]) as $array) { foreach ($array as $day => $meals) { foreach ($meals as $meal => $count) { $result[$day][$meal] = ($result[$day][$meal] ?? 0) + $count; } } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 33
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 33
Branch analysis from position: 14
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 31
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 31
Branch analysis from position: 16
2 jumps found. (Code = 77) Position 1 = 18, Position 2 = 29
Branch analysis from position: 18
2 jumps found. (Code = 78) Position 1 = 19, Position 2 = 29
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 29
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 31
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
filename:       /in/a13iC
function name:  (null)
number of ops:  38
compiled vars:  !0 = $arr1, !1 = $arr2, !2 = $arr3, !3 = $result, !4 = $array, !5 = $meals, !6 = $day, !7 = $count, !8 = $meal
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    8     1        ASSIGN                                                   !1, <array>
   13     2        ASSIGN                                                   !2, <array>
   17     3        ASSIGN                                                   !3, <array>
   18     4        INIT_FCALL                                               'array_merge'
          5        INIT_ARRAY                                       ~13     !0
          6        SEND_VAL                                                 ~13
          7        INIT_ARRAY                                       ~14     !1
          8        SEND_VAL                                                 ~14
          9        INIT_ARRAY                                       ~15     !2
         10        SEND_VAL                                                 ~15
         11        DO_ICALL                                         $16     
         12      > FE_RESET_R                                       $17     $16, ->33
         13    > > FE_FETCH_R                                               $17, !4, ->33
   19    14    > > FE_RESET_R                                       $18     !4, ->31
         15    > > FE_FETCH_R                                       ~19     $18, !5, ->31
         16    >   ASSIGN                                                   !6, ~19
   20    17      > FE_RESET_R                                       $21     !5, ->29
         18    > > FE_FETCH_R                                       ~22     $21, !7, ->29
         19    >   ASSIGN                                                   !8, ~22
   21    20        FETCH_DIM_IS                                     ~26     !3, !6
         21        FETCH_DIM_IS                                     ~27     ~26, !8
         22        COALESCE                                         ~28     ~27
         23        QM_ASSIGN                                        ~28     0
         24        ADD                                              ~29     ~28, !7
         25        FETCH_DIM_W                                      $24     !3, !6
         26        ASSIGN_DIM                                               $24, !8
         27        OP_DATA                                                  ~29
   20    28      > JMP                                                      ->18
         29    >   FE_FREE                                                  $21
   19    30      > JMP                                                      ->15
         31    >   FE_FREE                                                  $18
   18    32      > JMP                                                      ->13
         33    >   FE_FREE                                                  $17
   25    34        INIT_FCALL                                               'var_export'
         35        SEND_VAR                                                 !3
         36        DO_ICALL                                                 
         37      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.21 ms | 1006 KiB | 15 Q