3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array=array( 0 => array( 11 => 18.000, 14 => 25.100, 15 => 5.000, 16 => 8.000, 19 => 21.600 ), 1 => array( 11 => 9.100, 12 => 2.700, 14 => 2.300, 15 => 18.800, 16 => 9.500, 17 => 6.900, 19 => 9.400 ), 2 => array( 14 => 5.700 ), 3 => array( 17 => 2.800, 20 => 6.000 ), 4 => array( 24 => 5.000, 25 => 6.000, 26 => 2.7 ), 5 => array( 16 => 2.200 ), 6 => array( 14 => 13.000, 15 => 2.000, 16 => 4.300, 19 => 6.000 ), 7 => array( 32 => 5.000, 36 => 18.500 ) ); $result=[]; foreach($array as $subarray){ $subarray=array_diff_key($subarray,$result); // deny iteration of previously summed subarray keys foreach($subarray as $k=>$v){ $result[$k]=array_sum(array_column($array,$k)); // sum the whole array's column } } var_export($result);
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 = 10, Position 2 = 22
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 22
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
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/YQvGE
function name:  (null)
number of ops:  29
compiled vars:  !0 = $array, !1 = $result, !2 = $subarray, !3 = $v, !4 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   45     1        ASSIGN                                                   !1, <array>
   46     2      > FE_RESET_R                                       $7      !0, ->24
          3    > > FE_FETCH_R                                               $7, !2, ->24
   47     4    >   INIT_FCALL                                               'array_diff_key'
          5        SEND_VAR                                                 !2
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $8      
          8        ASSIGN                                                   !2, $8
   48     9      > FE_RESET_R                                       $10     !2, ->22
         10    > > FE_FETCH_R                                       ~11     $10, !3, ->22
         11    >   ASSIGN                                                   !4, ~11
   49    12        INIT_FCALL                                               'array_sum'
         13        INIT_FCALL                                               'array_column'
         14        SEND_VAR                                                 !0
         15        SEND_VAR                                                 !4
         16        DO_ICALL                                         $14     
         17        SEND_VAR                                                 $14
         18        DO_ICALL                                         $15     
         19        ASSIGN_DIM                                               !1, !4
         20        OP_DATA                                                  $15
   48    21      > JMP                                                      ->10
         22    >   FE_FREE                                                  $10
   46    23      > JMP                                                      ->3
         24    >   FE_FREE                                                  $7
   52    25        INIT_FCALL                                               'var_export'
         26        SEND_VAR                                                 !1
         27        DO_ICALL                                                 
         28      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.44 ms | 1401 KiB | 21 Q