Home > php教程 > php手册 > body text

php-Arrays函数-array_count_values-统计数组中所有值的出现次数

WBOY
Release: 2016-06-13 10:49:39
Original
1032 people have browsed it

array_count_values() 函数

【功能】
         该函数将返回一个数组,
         该数组用input数组中的值作为键名,
         该值在input数组中出现的次数作为值
【使用范围】
         php4、php5
【使用】
         array array_count_values( array input )
         input/必需/被统计的数组
【示例】
[php]
        $arr = array( "key1" => "val1", "key2" => "val2", 
                      "key3" => "val1", "key4" => "val4" ); 
        print_r( array_count_values( $arr ) ); 
/*
Array
(
    [val1] => 2
    [val2] => 1
    [val4] => 1
)
*/ 

 


摘自 zuodefeng的笔记

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 Recommendations
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!