- array_count_values: documentation ( source)
- array_column: documentation ( source)
- print_r: documentation ( source)
<?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);