How to count the same value in an array using PHP

If you want to get duplicate values count in an array,this method can be use easily.It will display array values all count.

$array = array("A","B","C","A","C");
print_r(array_count_values($array));

Output

Array ( [A] => 2 [B] => 1 [C] => 2 ) 

Leave a Reply

Your email address will not be published. Required fields are marked *