3v4l.org

run code in 500+ 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 = 22
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 22
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 17
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/a0Cfa
function name:  (null)
number of ops:  30
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, ->22
          3    > > FE_FETCH_R                                                   $6, !2, ->22
   13     4    >   INIT_FCALL                                                   'array_slice'
          5        SEND_VAR                                                     !2
          6        SEND_VAL                                                     0
          7        SEND_VAL                                                     3
          8        DO_ICALL                                             $7      
          9        FRAMELESS_ICALL_2                implode             ~8      '%7E', $7
         10        ASSIGN                                                       !3, ~8
   14    11        ISSET_ISEMPTY_DIM_OBJ                             0  ~10     !1, !3
         12        BOOL_NOT                                             ~11     ~10
         13      > JMPZ                                                         ~11, ->17
   15    14    >   ASSIGN_DIM                                                   !1, !3
         15        OP_DATA                                                      !2
   14    16      > JMP                                                          ->21
   17    17    >   FETCH_DIM_R                                          ~15     !2, 'count'
         18        FETCH_DIM_RW                                         $13     !1, !3
         19        ASSIGN_DIM_OP                    +=               1          $13, 'count'
         20        OP_DATA                                                      ~15
   12    21    > > JMP                                                          ->3
         22    >   FE_FREE                                                      $6
   21    23        INIT_FCALL                                                   'var_export'
         24        INIT_FCALL                                                   'array_values'
         25        SEND_VAR                                                     !1
         26        DO_ICALL                                             $16     
         27        SEND_VAR                                                     $16
         28        DO_ICALL                                                     
         29      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
212.47 ms | 1965 KiB | 16 Q