array_count_values php
snippet in php

array_count_values php

user1217

<?php
$a=array("A","Cat","Dog","A","Dog");
print_r(array_count_values($a));
?>
 

php count amount of times a value appears in array

user6972

$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