group and count repeated values in php array code example
Example 1: php count amount of times a value appears in array
$tmp = array_count_values($uid);
$cnt = $tmp[12];
//Or
$cnt = count(array_filter($uid,function($a) {return $a==12;}));
//In both cases $var will be a number
Example 2: php group array by value and count
$colors=array("red","red","red","blue","green");
$colorsCount=array_count_values($colors);
print_r($colorsCount);
#Array
#(
# [red] => 3
# [blue] => 1
# [green] => 1
#)