Home > Backend Development > PHP Tutorial > php-Arrays function-array_count_values-counts the occurrences of all values ​​in an array_PHP tutorial

php-Arrays function-array_count_values-counts the occurrences of all values ​​in an array_PHP tutorial

WBOY
Release: 2016-07-13 17:51:27
Original
1075 people have browsed it

array_count_values() function

【Function】
This function will return an array,
This array uses the value in the input array as the key name,
The number of times this value appears in the input array is used as the value
【Scope of use】
​​​​ php4, php5
【Use】
array array_count_values(array input)
                                                                                                                                                                                                                                                                          × × × × × / × / × ‐ [             〉 【Example】
[php]
          $arr = array( "key1" => "val1", "key2" => "val2",
"key3" => "val1", "key4" => "val4" );
            print_r( array_count_values( $arr ) );
/*
Array
(
[val1] => 2
[val2] => 1
[val4] => 1
)
*/

Excerpted from zuodefeng’s notes

http://www.bkjia.com/PHPjc/478198.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478198.htmlTechArticlearray_count_values() function [Function] This function will return an array using the values ​​in the input array as keys Name, the number of times the value appears in the input array as the value [Use scope...
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