Table example:
| Ti | Orien |
| ---| JML |
| ---| JML |
| ---| RGM |
| ---| AAA |
| ---| AAA |
Example result: JML - 2 RGM - 1 AAA - 2
Table example:
| Ti | Orien |
| ---| JML |
| ---| JML |
| ---| RGM |
| ---| AAA |
| ---| AAA |
Example result: JML - 2 RGM - 1 AAA - 2
With php5.5 you can combine the array_column()
function to extract the index values and return them as a new array, using the array_count_values()
function that says how many equal values there are in the array, the keys are the values of the database and the values are the number of occurrences.
$arr = [['str' => 'abc'], ['str' => 2015], ['str' => 2015], ['str' => 'doge'], ['str' => 'wow'], ['str' => 'wow']];
$itens = array_count_values(array_column($arr, 'str'));
echo "<pre>";
print_r($itens);
Return:
Array
(
[abc] => 1
[2015] => 2
[doge] => 1
[wow] => 2
)