Home  >  Article  >  php教程  >  php-Arrays函数-array_count_values-统计数组中所有值的出现次数

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

WBOY
WBOYOriginal
2016-06-13 10:49:391057browse

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的笔记

Statement:
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