3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr=array( Array ( 0 => 3, 1 => 1 ), Array ( 0 => 3, 1 => 2 ), Array ( 0 => 3, 1 => 128 ), Array ( 0 => 39, 1 => 4 )); $col0 = array_column($arr, 0); $col1 = array_column($arr, 1); Foreach(array_unique($col0) as $val){ $res[] = [$val, array_sum(array_intersect_key($col1, array_intersect($col0,[$val])))]; } Var_dump($res);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 33
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 33
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
filename:       /in/gKb5b
function name:  (null)
number of ops:  38
compiled vars:  !0 = $arr, !1 = $col0, !2 = $col1, !3 = $val, !4 = $res
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   25     1        INIT_FCALL                                               'array_column'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 0
          4        DO_ICALL                                         $6      
          5        ASSIGN                                                   !1, $6
   26     6        INIT_FCALL                                               'array_column'
          7        SEND_VAR                                                 !0
          8        SEND_VAL                                                 1
          9        DO_ICALL                                         $8      
         10        ASSIGN                                                   !2, $8
   28    11        INIT_FCALL                                               'array_unique'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                         $10     
         14      > FE_RESET_R                                       $11     $10, ->33
         15    > > FE_FETCH_R                                               $11, !3, ->33
   29    16    >   INIT_ARRAY                                       ~13     !3
         17        INIT_FCALL                                               'array_sum'
         18        INIT_FCALL                                               'array_intersect_key'
         19        SEND_VAR                                                 !2
         20        INIT_FCALL                                               'array_intersect'
         21        SEND_VAR                                                 !1
         22        INIT_ARRAY                                       ~14     !3
         23        SEND_VAL                                                 ~14
         24        DO_ICALL                                         $15     
         25        SEND_VAR                                                 $15
         26        DO_ICALL                                         $16     
         27        SEND_VAR                                                 $16
         28        DO_ICALL                                         $17     
         29        ADD_ARRAY_ELEMENT                                ~13     $17
         30        ASSIGN_DIM                                               !4
         31        OP_DATA                                                  ~13
   28    32      > JMP                                                      ->15
         33    >   FE_FREE                                                  $11
   31    34        INIT_FCALL                                               'var_dump'
         35        SEND_VAR                                                 !4
         36        DO_ICALL                                                 
         37      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.97 ms | 1017 KiB | 19 Q