PHP calculates the code for the number of occurrences of the same value in an array (array_count_values), arraycountvalues
PHP calculates the number of occurrences of the same value in an array, using PHP's own function array_count_values
:
Description
Array array_count_values (array $input) Array_count_values () returns an array that uses the value in the input array as the key name, and the number of occurrences in the input array as the value.
Array_count_values () example
Copy the Code code as follows:
<?php
$array = Array (1, "Hello", 1, "World", "Hello");
Print_r (Array_count_values ($array));
?>
The above routines will output:
Copy the Code code as follows:
Array
(
[1] = 2
[Hello] = 2
[World] = 1
)
http://www.bkjia.com/PHPjc/945713.html www.bkjia.com true http://www.bkjia.com/PHPjc/945713.html techarticle PHP calculates the number of occurrences of the same value in the array code (array_count_values), arraycountvalues PHP computes the same number of occurrences of the array, you can use the PHP self-function array_count_values: Description ...