Home >Backend Development >PHP Tutorial >values ​​php array function sequence array_count_values ​​counts the number of occurrences of all values ​​in the array function

values ​​php array function sequence array_count_values ​​counts the number of occurrences of all values ​​in the array function

WBOY
WBOYOriginal
2016-07-29 08:47:011043browse

array_count_values() definition and usage
array_count_values() function is used to count the number of occurrences of all values ​​in an array.
This function returns an array, the key name of its element is the value of the original array, and the key value is the number of times the value appears in the original array.
Syntax
array_count_values(array) Parameter Description
array Required. Specifies the input array.
Example

Copy code The code is as follows:


$a=array("Cat","Dog","Horse","Dog");
print_r(array_count_values($a ));
?>


Output:
Array ( [Cat] => 1 [Dog] => 2 [Horse] => 1 )

The above introduces the values ​​php array function sequence array_count_values ​​function that counts the number of occurrences of all values ​​in the array, including the contents of values. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn