3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array=[ ['NDC_ItemType'=>'Night','NDC_Item'=>'Night','NDC_Quantity'=>1], ['NDC_ItemType'=>'Night','NDC_Item'=>'Night','NDC_Quantity'=>1], ['NDC_ItemType'=>'Night','NDC_Item'=>'Night','NDC_Quantity'=>1], ['NDC_ItemType'=>'Night','NDC_Item'=>'Night','NDC_Quantity'=>1], ['NDC_ItemType'=>'Night','NDC_Item'=>'Night','NDC_Quantity'=>1], ['NDC_ItemType'=>'Item','NDC_Item'=>'Hot-Dog','NDC_Quantity'=>5] ]; foreach($array as $row){ if(!isset($result[$row['NDC_ItemType']])){ $result[$row['NDC_ItemType']]=$row['NDC_Quantity']; }else{ $result[$row['NDC_ItemType']]+=$row['NDC_Quantity']; } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 17
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 17
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 12
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/HvVNZ
function name:  (null)
number of ops:  22
compiled vars:  !0 = $array, !1 = $row, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   11     1      > FE_RESET_R                                       $4      !0, ->17
          2    > > FE_FETCH_R                                               $4, !1, ->17
   12     3    >   FETCH_DIM_R                                      ~5      !1, 'NDC_ItemType'
          4        ISSET_ISEMPTY_DIM_OBJ                         0  ~6      !2, ~5
          5        BOOL_NOT                                         ~7      ~6
          6      > JMPZ                                                     ~7, ->12
   13     7    >   FETCH_DIM_R                                      ~8      !1, 'NDC_ItemType'
          8        FETCH_DIM_R                                      ~10     !1, 'NDC_Quantity'
          9        ASSIGN_DIM                                               !2, ~8
         10        OP_DATA                                                  ~10
         11      > JMP                                                      ->16
   15    12    >   FETCH_DIM_R                                      ~11     !1, 'NDC_ItemType'
         13        FETCH_DIM_R                                      ~13     !1, 'NDC_Quantity'
         14        ASSIGN_DIM_OP                +=               1          !2, ~11
         15        OP_DATA                                                  ~13
   11    16    > > JMP                                                      ->2
         17    >   FE_FREE                                                  $4
   18    18        INIT_FCALL                                               'var_export'
         19        SEND_VAR                                                 !2
         20        DO_ICALL                                                 
         21      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
125.63 ms | 1400 KiB | 15 Q