3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ['group' => 1, 'animal' => 'ape'], ['group' => 1, 'animal' => 'bat'], ['group' => 1, 'animal' => 'cat'], ['group' => 2, 'animal' => 'dog'], ['group' => 1, 'animal' => 'eel'], ['group' => 3, 'animal' => 'fox'], ['group' => 1, 'animal' => 'gnu'], ['group' => 2, 'animal' => 'hog'], ]; $result = []; foreach ($array as $row) { $result[$row['group']] ??= $row + ['count' => 0]; ++$result[$row['group']]['count']; } var_export(array_values($result));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 20
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 20
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/QJX8V
function name:  (null)
number of ops:  28
compiled vars:  !0 = $array, !1 = $result, !2 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   14     1        ASSIGN                                                   !1, <array>
   15     2      > FE_RESET_R                                       $5      !0, ->20
          3    > > FE_FETCH_R                                               $5, !2, ->20
   16     4    >   FETCH_DIM_R                                      ~6      !2, 'group'
          5        COPY_TMP                                         ~7      ~6
          6        FETCH_DIM_IS                                     ~8      !1, ~6
          7        COALESCE                                         ~9      ~8
          8        ADD                                              ~10     !2, <array>
          9        ASSIGN_DIM                                       ~11     !1, ~7
         10        OP_DATA                                                  ~10
         11        QM_ASSIGN                                        ~9      ~11
         12      > JMP                                                      ->14
         13*       FREE                                                     ~7
         14    >   FREE                                                     ~9
   17    15        FETCH_DIM_R                                      ~12     !2, 'group'
         16        FETCH_DIM_RW                                     $13     !1, ~12
         17        FETCH_DIM_RW                                     $14     $13, 'count'
         18        PRE_INC                                                  $14
   15    19      > JMP                                                      ->3
         20    >   FE_FREE                                                  $5
   19    21        INIT_FCALL                                               'var_export'
         22        INIT_FCALL                                               'array_values'
         23        SEND_VAR                                                 !1
         24        DO_ICALL                                         $16     
         25        SEND_VAR                                                 $16
         26        DO_ICALL                                                 
         27      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.15 ms | 1012 KiB | 15 Q