PHP array_count_values() 函数

PHP 教程 · 2019-01-22 05:58:11

实例

统计数组中所有值出现的次数:

<?php
$a=array("A","Cat","Dog","A","Dog");
print_r(array_count_values($a));
?>

定义和用法

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

语法


array_count_values(array)

参数 描述
array 必需。规定需要统计数组中所有值出现次数的数组。

技术细节

返回值: 返回一个关联数组,其元素的键名是原数组的值,键值是该值在原数组中出现的次数。
PHP 版本: 4+

点击查看所有 PHP 教程 文章: https://codercto.com/courses/l/5.html

查看所有标签

Algorithms and Data Structures

Algorithms and Data Structures

Kurt Mehlhorn、Peter Sanders / Springer / 2008-08-06 / USD 49.95

Algorithms are at the heart of every nontrivial computer application, and algorithmics is a modern and active area of computer science. Every computer scientist and every professional programmer shoul......一起来看看 《Algorithms and Data Structures》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

在线进制转换器
在线进制转换器

各进制数互转换器

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具