3v4l.org

run code in 300+ PHP versions simultaneously
<?php $search = Array( 'RED' => Array ( 'AP' => 2 ), 'BLUE' => Array ( 'OR' => 5, 'GR' => 3, 'PL' => 2, 'BL' => 1 ), 'YELLOW' => Array ( 'LI' => 7, 'OR' => 4, 'GR' => 3, 'PL' => 4 ) ); $arr = array(); foreach ($search as $srch_val => $srch_row) { foreach ($srch_row as $key => $val) { if(array_key_exists($key, $arr)) { $arr[$key] = $arr[$key] + ($val); } else { $arr[$key] = ($val); } } } print_r($arr);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 20
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 20
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 18
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 18
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 15
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 18
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/ZP0Zd
function name:  (null)
number of ops:  25
compiled vars:  !0 = $search, !1 = $arr, !2 = $srch_row, !3 = $srch_val, !4 = $val, !5 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   24     1        ASSIGN                                                   !1, <array>
   26     2      > FE_RESET_R                                       $8      !0, ->20
          3    > > FE_FETCH_R                                       ~9      $8, !2, ->20
          4    >   ASSIGN                                                   !3, ~9
   27     5      > FE_RESET_R                                       $11     !2, ->18
          6    > > FE_FETCH_R                                       ~12     $11, !4, ->18
          7    >   ASSIGN                                                   !5, ~12
   28     8        ARRAY_KEY_EXISTS                                         !5, !1
          9      > JMPZ                                                     ~14, ->15
   29    10    >   FETCH_DIM_R                                      ~16     !1, !5
         11        ADD                                              ~17     ~16, !4
         12        ASSIGN_DIM                                               !1, !5
         13        OP_DATA                                                  ~17
   28    14      > JMP                                                      ->17
   31    15    >   ASSIGN_DIM                                               !1, !5
         16        OP_DATA                                                  !4
   27    17    > > JMP                                                      ->6
         18    >   FE_FREE                                                  $11
   26    19      > JMP                                                      ->3
         20    >   FE_FREE                                                  $8
   36    21        INIT_FCALL                                               'print_r'
         22        SEND_VAR                                                 !1
         23        DO_ICALL                                                 
         24      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.76 ms | 999 KiB | 14 Q