Home > Backend Development > PHP Tutorial > PHP array function sequence array_count_values() counts the number of occurrences of all values ​​in the array_PHP tutorial

PHP array function sequence array_count_values() counts the number of occurrences of all values ​​in the array_PHP tutorial

WBOY
Release: 2016-07-21 15:23:29
Original
1024 people have browsed it

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 )

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/324495.htmlTechArticlearray_count_values() definition and usage The 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, the key...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template