3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input_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] ]; $dlv_id = array_column($input_array, 'dlv_id', 'cust_id'); // get all no_of_subs maintaining the cust_id as index $no_of_subs = array_column($input_array, 'no_of_subs', 'cust_id'); $output = array(); foreach ($dlv_id as $key => $value) { if (isset($output[$value]['dlv_id'])) { $output[$value]['dlv_id'] += $no_of_subs[$key]; } else { $output[$value]['dlv_id'] += $no_of_subs[$key]; } } var_export($output);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 30
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 30
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 25
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/irHJT
function name:  (null)
number of ops:  35
compiled vars:  !0 = $input_array, !1 = $dlv_id, !2 = $no_of_subs, !3 = $output, !4 = $value, !5 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    9     1        INIT_FCALL                                               'array_column'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 'dlv_id'
          4        SEND_VAL                                                 'cust_id'
          5        DO_ICALL                                         $7      
          6        ASSIGN                                                   !1, $7
   12     7        INIT_FCALL                                               'array_column'
          8        SEND_VAR                                                 !0
          9        SEND_VAL                                                 'no_of_subs'
         10        SEND_VAL                                                 'cust_id'
         11        DO_ICALL                                         $9      
         12        ASSIGN                                                   !2, $9
   14    13        ASSIGN                                                   !3, <array>
   16    14      > FE_RESET_R                                       $12     !1, ->30
         15    > > FE_FETCH_R                                       ~13     $12, !4, ->30
         16    >   ASSIGN                                                   !5, ~13
   18    17        FETCH_DIM_IS                                     ~15     !3, !4
         18        ISSET_ISEMPTY_DIM_OBJ                         0          ~15, 'dlv_id'
         19      > JMPZ                                                     ~16, ->25
   19    20    >   FETCH_DIM_R                                      ~19     !2, !5
         21        FETCH_DIM_RW                                     $17     !3, !4
         22        ASSIGN_DIM_OP                +=               1          $17, 'dlv_id'
         23        OP_DATA                                                  ~19
   18    24      > JMP                                                      ->29
   21    25    >   FETCH_DIM_R                                      ~22     !2, !5
         26        FETCH_DIM_RW                                     $20     !3, !4
         27        ASSIGN_DIM_OP                +=               1          $20, 'dlv_id'
         28        OP_DATA                                                  ~22
   16    29    > > JMP                                                      ->15
         30    >   FE_FREE                                                  $12
   24    31        INIT_FCALL                                               'var_export'
         32        SEND_VAR                                                 !3
         33        DO_ICALL                                                 
         34      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.39 ms | 1007 KiB | 15 Q