php数组函数序列 之array_count_values() 统计数组中所有值出现的次数函数_PHP教程

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

array_count_values()定义和用法
array_count_values() 函数用于统计数组中所有值出现的次数。

本函数返回一个数组,其元素的键名是原数组的值,键值是该值在原数组中出现的次数。

语法
array_count_values(array) 参数 描述
array 必需。规定输入的数组。

例子

复制代码 代码如下:

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

输出:

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

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/324495.htmlTechArticlearray_count_values()定义和用法 array_count_values() 函数用于统计数组中所有值出现的次数。 本函数返回一个数组,其元素的键名是原数组的值,键...
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!