3v4l.org

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
238.18 ms | 1009 KiB | 17 Q