3v4l.org

run code in 300+ PHP versions simultaneously
<?php $ar = array ( 'Services' => array( array ( '9' => '0', '10' => '0', '11' => '0', '12' => '0', '13' => '0', '14' => '0', '15' => '600' ), ), 'Financial' => array( Array ( '9' => 0, '10' => 0, '11' => 0, '12' => 0, '13' => 0, '14' => 0, '15' => 500 ), Array ( '9' => 0, '10' => 0, '11' => 0, '12' => 0, '13' => 0, '14' => 0, '15' => 200 ), Array ( '9' => 0, '10' => 0, '11' => 0, '12' => 0, '13' => 0, '14' => 0, '15' => 300 ), ), 'DFD' => array( Array ( '9' => 0, '10' => 0, '11' => 0, '12' => 0, '13' => 0, '14' => 0, '15' => 1000, ), Array ( '9' => 0, '10' => 0, '11' => 0, '12' => 0, '13' => 0, '14' => 0, '15' => 100 ) ) ); $finalArray = []; foreach($ar as $key=>$val){ $keyIndexes = array_keys($val[0]); foreach($keyIndexes as $keyIndex){ $finalArray[$key][$keyIndex] = array_sum(array_column($val,$keyIndex)); } } print_r($finalArray);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 25
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 25
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 23
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 23
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
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/mEC6l
function name:  (null)
number of ops:  30
compiled vars:  !0 = $ar, !1 = $finalArray, !2 = $val, !3 = $key, !4 = $keyIndexes, !5 = $keyIndex
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   80     1        ASSIGN                                                   !1, <array>
   82     2      > FE_RESET_R                                       $8      !0, ->25
          3    > > FE_FETCH_R                                       ~9      $8, !2, ->25
          4    >   ASSIGN                                                   !3, ~9
   84     5        INIT_FCALL                                               'array_keys'
          6        FETCH_DIM_R                                      ~11     !2, 0
          7        SEND_VAL                                                 ~11
          8        DO_ICALL                                         $12     
          9        ASSIGN                                                   !4, $12
   85    10      > FE_RESET_R                                       $14     !4, ->23
         11    > > FE_FETCH_R                                               $14, !5, ->23
   86    12    >   INIT_FCALL                                               'array_sum'
         13        INIT_FCALL                                               'array_column'
         14        SEND_VAR                                                 !2
         15        SEND_VAR                                                 !5
         16        DO_ICALL                                         $17     
         17        SEND_VAR                                                 $17
         18        DO_ICALL                                         $18     
         19        FETCH_DIM_W                                      $15     !1, !3
         20        ASSIGN_DIM                                               $15, !5
         21        OP_DATA                                                  $18
   85    22      > JMP                                                      ->11
         23    >   FE_FREE                                                  $14
   82    24      > JMP                                                      ->3
         25    >   FE_FREE                                                  $8
   90    26        INIT_FCALL                                               'print_r'
         27        SEND_VAR                                                 !1
         28        DO_ICALL                                                 
         29      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
201.73 ms | 1006 KiB | 17 Q