Hello friends,
If you want to count all the values in an array means you want that how much time a value is exist in an array then you can use a predefined PHP function which is "array_count_values()". array_count_values() returns an array using the values of an array as keys and their frequency as values. It means this function returns an array in which value is used as key and it's counting is used as a value.
Here is a example which will explain you this function-
<?php
$array = array("Hi",2, "hello", 2, "world", "hello");
print_r(array_count_values($array));
?>
Output:
Array
(
[Hi] => 1
[2] => 2
[hello] => 2
[world] => 1
)
0 Comment(s)