Home php教程 php手册 php数组函数序列 之array_count_values() 统计数组中所有值出现

php数组函数序列 之array_count_values() 统计数组中所有值出现

Jun 06, 2016 pm 08:39 PM
array_count_values

array_count_values() 函数用于统计数组中所有值出现的次数,本函数返回一个数组,其元素的键名是原数组的值,键值是该值在原数组中出现的次数。

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 )
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)