Current Location: Home> Function Categories> array_count_values

array_count_values

Count the number of values ​​in the array
Name:array_count_values
Category:Array
Programming Language:php
One-line Description:Used to count the number of times all values ​​appear in the array.

Definition and usage

The array_count_values() function counts all values ​​in the array.

illustrate

The array_count_values() function is used to count the number of times all values ​​appear in an array.

This function returns an array whose element's key name is the value of the original array, and the key value is the number of times the value appears in the original array.

Example

Count all values ​​in the array:

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

Try it yourself

grammar

 array_count_values ​​( array )
parameter describe
array Required. Specifies an array that needs to count values.