Skip links

PHP get duplicate values count in an array

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

$myArray = array("one", "two", "three","four","five","one","four");
$my_array_values = array_count_values($myArray);
while (list ($key, $val) = each ($my_array_values))
{
   echo "$key -> $val "."  times"."
"; }