3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ["cust_id" => 1006, "no_of_subs" => 2, "dlv_id" => 1000], ["cust_id" => 1011, "no_of_subs" => 3, "dlv_id" => 1000], ["cust_id" => 1012, "no_of_subs" => 5, "dlv_id" => 1001], ["cust_id" => 1013, "no_of_subs" => 6, "dlv_id" => 1001] ]; foreach ($array as $row) { if (!isset($result[$row["dlv_id"]])) { $result[$row["dlv_id"]] = ["dlv_id" => $row["dlv_id"], "no_of_subs" => $row["no_of_subs"]]; } else { $result[$row["dlv_id"]]["no_of_subs"] += $row["no_of_subs"]; } } var_export(array_values($result));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 21
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 21
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 15
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/UIpKa
function name:  (null)
number of ops:  29
compiled vars:  !0 = $array, !1 = $row, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    9     1      > FE_RESET_R                                       $4      !0, ->21
          2    > > FE_FETCH_R                                               $4, !1, ->21
   10     3    >   FETCH_DIM_R                                      ~5      !1, 'dlv_id'
          4        ISSET_ISEMPTY_DIM_OBJ                         0  ~6      !2, ~5
          5        BOOL_NOT                                         ~7      ~6
          6      > JMPZ                                                     ~7, ->15
   11     7    >   FETCH_DIM_R                                      ~8      !1, 'dlv_id'
          8        FETCH_DIM_R                                      ~10     !1, 'dlv_id'
          9        INIT_ARRAY                                       ~11     ~10, 'dlv_id'
         10        FETCH_DIM_R                                      ~12     !1, 'no_of_subs'
         11        ADD_ARRAY_ELEMENT                                ~11     ~12, 'no_of_subs'
         12        ASSIGN_DIM                                               !2, ~8
         13        OP_DATA                                                  ~11
   10    14      > JMP                                                      ->20
   13    15    >   FETCH_DIM_R                                      ~13     !1, 'dlv_id'
         16        FETCH_DIM_R                                      ~16     !1, 'no_of_subs'
         17        FETCH_DIM_RW                                     $14     !2, ~13
         18        ASSIGN_DIM_OP                +=               1          $14, 'no_of_subs'
         19        OP_DATA                                                  ~16
    9    20    > > JMP                                                      ->2
         21    >   FE_FREE                                                  $4
   16    22        INIT_FCALL                                               'var_export'
         23        INIT_FCALL                                               'array_values'
         24        SEND_VAR                                                 !2
         25        DO_ICALL                                         $17     
         26        SEND_VAR                                                 $17
         27        DO_ICALL                                                 
         28      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.19 ms | 1004 KiB | 15 Q