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_recursive($arr1, $arr2, $arr3) as $day => $meals) { foreach ($meals as $meal => $counts) { $result[$day][$meal] = array_sum((array)$counts); } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 25
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 25
Branch analysis from position: 11
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 23
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 23
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 23
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/S0LBa
function name:  (null)
number of ops:  30
compiled vars:  !0 = $arr1, !1 = $arr2, !2 = $arr3, !3 = $result, !4 = $meals, !5 = $day, !6 = $counts, !7 = $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_recursive'
          5        SEND_VAR                                                 !0
          6        SEND_VAR                                                 !1
          7        SEND_VAR                                                 !2
          8        DO_ICALL                                         $12     
          9      > FE_RESET_R                                       $13     $12, ->25
         10    > > FE_FETCH_R                                       ~14     $13, !4, ->25
         11    >   ASSIGN                                                   !5, ~14
   19    12      > FE_RESET_R                                       $16     !4, ->23
         13    > > FE_FETCH_R                                       ~17     $16, !6, ->23
         14    >   ASSIGN                                                   !7, ~17
   20    15        INIT_FCALL                                               'array_sum'
         16        CAST                                          7  ~21     !6
         17        SEND_VAL                                                 ~21
         18        DO_ICALL                                         $22     
         19        FETCH_DIM_W                                      $19     !3, !5
         20        ASSIGN_DIM                                               $19, !7
         21        OP_DATA                                                  $22
   19    22      > JMP                                                      ->13
         23    >   FE_FREE                                                  $16
   18    24      > JMP                                                      ->10
         25    >   FE_FREE                                                  $13
   24    26        INIT_FCALL                                               'var_export'
         27        SEND_VAR                                                 !3
         28        DO_ICALL                                                 
         29      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.44 ms | 1003 KiB | 16 Q