PHP array_count_values() functionThe array_count_values() function returns an array where the keys are the original array's values, and the values is the number of occurrences. In other words, we can say that array_count_values() function is used to calculate the frequency of all of the elements of an array. Syntax
Return TypeReturns an associative array, where the keys are the original array's values, and the values are the number of occurrences. This function is introduced in PHP 4 Example 1Output: Array( [3] => 2 [Hii] => 2 [World] => 1 ) Example 2Output: Array( [php] => 3 [T] => 2 [Point] => 1 ) Example 3Output: Array ( [Ajay]=>2 [Sid]=>2 [Rahul]=>1 [Ashish]=>1 ) Example 4Output: Array ( [Cricket] => 1 [Hockey] => 2 [Football] => 1 )
Next TopicPHP Array Functions
|