PHP counts the number of each value in an array

array_count_values(): Count the number of times each specific value has appeared in the array $array;

$array = [1,2,3,4,2,2,3,4,5];
$count = array_count_values($array);

Print result:

Guess you like

Origin blog.csdn.net/I_lost/article/details/114438083