3v4l.org

run code in 300+ PHP versions simultaneously
<?php $items = array( '1_JAN_2017' => array('1' => array(2, 5, 3), '2' => array(3, 2, 6, 9)), '2_JAN_2017' => array('1' => array(3, 9), '3' => array(1, 4, 8)), '3_JAN_2017' => array('4' => array(9), '1' => array(2, 7, 5, 2)), '4_JAN_2017' => array('1' => array(5, 3, 3, 2), '4' => array(4, 9, 8, 5)), '5_JAN_2017' => array('2' => array(8, 5), '5' => array(3, 9, 7)), '6_JAN_2017' => array('5' => array(2, 1, 7, 5), '4' => array(1, 9, 6)), '7_JAN_2017' => array('4' => array(5, 2, 9), '3' => array(4, 1, 6)) ); $sumArray = []; foreach ($items as $date) { foreach ($date as $key => $amounts) { if (!array_key_exists($key, $sumArray)) { $sumArray[$key] = array_sum($amounts); continue; } $sumArray[$key] += array_sum($amounts); } } print_r($sumArray);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 24
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 24
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 22
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 22
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 16
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
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/RKANK
function name:  (null)
number of ops:  29
compiled vars:  !0 = $items, !1 = $sumArray, !2 = $date, !3 = $amounts, !4 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   13     1        ASSIGN                                                   !1, <array>
   14     2      > FE_RESET_R                                       $7      !0, ->24
          3    > > FE_FETCH_R                                               $7, !2, ->24
   15     4    > > FE_RESET_R                                       $8      !2, ->22
          5    > > FE_FETCH_R                                       ~9      $8, !3, ->22
          6    >   ASSIGN                                                   !4, ~9
   16     7        ARRAY_KEY_EXISTS                                 ~11     !4, !1
          8        BOOL_NOT                                         ~12     ~11
          9      > JMPZ                                                     ~12, ->16
   17    10    >   INIT_FCALL                                               'array_sum'
         11        SEND_VAR                                                 !3
         12        DO_ICALL                                         $14     
         13        ASSIGN_DIM                                               !1, !4
         14        OP_DATA                                                  $14
   18    15      > JMP                                                      ->5
   20    16    >   INIT_FCALL                                               'array_sum'
         17        SEND_VAR                                                 !3
         18        DO_ICALL                                         $16     
         19        ASSIGN_DIM_OP                +=               1          !1, !4
         20        OP_DATA                                                  $16
   15    21      > JMP                                                      ->5
         22    >   FE_FREE                                                  $8
   14    23      > JMP                                                      ->3
         24    >   FE_FREE                                                  $7
   23    25        INIT_FCALL                                               'print_r'
         26        SEND_VAR                                                 !1
         27        DO_ICALL                                                 
         28      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.58 ms | 1002 KiB | 15 Q