How do I count the number of times a value appears in an array?
Here's an example of this easy to use function so that you can see just how it works:
$values = array(1,1,1,2,2,2,2,3,3,4,2,5,1,3,5,3,1,5);
$most_popular = array_count_values($values);
This prints the following:
 => 5
 => 5
 => 4
 => 1
 => 3
So you can see it returns an array with the values of the initial array as the keys of the new array, with the number of times each value was present in the initial array as the value in the new array.
More arrays PHP QuestionsHow can I display a 2 dimensonal array?
How can I display values in a two dimensional array?
How do I find the size of an array?
What is the starting salary of Php developer in india?? after 1 year experience how much i could get??
How do I add to the end of an array and know how large the array is?