3v4l.org

run code in 300+ PHP versions simultaneously
<?php $rows = [ (object)['group' => 'a', 'other_col' => 'a'], (object)['group' => 'b', 'other_col' => 'a'], (object)['group' => 'a', 'other_col' => 'a'], (object)['group' => 'a', 'other_col' => 'a'], (object)['group' => 'c', 'other_col' => 'a'], ]; $groups = array_count_values(array_column($rows, 'group')); print_r($groups);

preferences:
31.34 ms | 406 KiB | 5 Q