3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = Array ( 0 => Array ( 'CSTNOC' => 1976, 'TOTALQTY' => 2 ), 1 => Array ( 'CSTNOC' => 5400, 'TOTALQTY' => 1 ), 2 => Array ( 'CSTNOC' => 5400, 'TOTALQTY' => 2 ) ); $new = array(); foreach($arr as $k=>$v){ $new[$v['CSTNOC']] = isset($new[$v['CSTNOC']]) ? $new[$v['CSTNOC']] + $v['TOTALQTY'] : $v['TOTALQTY']; } print_r($new);
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 = 43) Position 1 = 9, Position 2 = 15
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/mPtDX
function name:  (null)
number of ops:  25
compiled vars:  !0 = $arr, !1 = $new, !2 = $v, !3 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   23     1        ASSIGN                                                   !1, <array>
   24     2      > FE_RESET_R                                       $6      !0, ->20
          3    > > FE_FETCH_R                                       ~7      $6, !2, ->20
          4    >   ASSIGN                                                   !3, ~7
   25     5        FETCH_DIM_R                                      ~9      !2, 'CSTNOC'
          6        FETCH_DIM_R                                      ~11     !2, 'CSTNOC'
          7        ISSET_ISEMPTY_DIM_OBJ                         0          !1, ~11
          8      > JMPZ                                                     ~12, ->15
          9    >   FETCH_DIM_R                                      ~13     !2, 'CSTNOC'
         10        FETCH_DIM_R                                      ~14     !1, ~13
         11        FETCH_DIM_R                                      ~15     !2, 'TOTALQTY'
         12        ADD                                              ~16     ~14, ~15
         13        QM_ASSIGN                                        ~17     ~16
         14      > JMP                                                      ->17
         15    >   FETCH_DIM_R                                      ~18     !2, 'TOTALQTY'
         16        QM_ASSIGN                                        ~17     ~18
         17    >   ASSIGN_DIM                                               !1, ~9
         18        OP_DATA                                                  ~17
   24    19      > JMP                                                      ->3
         20    >   FE_FREE                                                  $6
   27    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:
151.23 ms | 1003 KiB | 14 Q