PHP function count the number of times array_count_values array of all the values appear

array_count_values ​​() function is used to count the number of times an array of all the values ​​that appears.

array_count_values()

PHP array_count_values ​​() function is used to count the number of times an array of all the values ​​appear, returns an array, the keys of its elements is the value of the original array, the key is the number of occurrences of the value in the original array.

grammar:

1
array array_count_values array array )

example:

1
2
3
4
<?php
$arr_a array ( "a" "b" "a" , 1);
print_r( array_count_values ( $arr_a ));
?>

Output:

1
2
3
4
5
6
Array
(
     [a] => 2
     [b] => 1
     [1] => 1
)

 

Guess you like

Origin www.cnblogs.com/todarcy/p/10984130.html