By default PHP has two methods for count array.
- array_count_values
- count
array_count_values()
Using this function, the number of times a value
in an array can be determined.
Example :
<?php $array = array(1, "hello", 1, "world", "hello"); print_r(array_count_values($array)); ?>
Result :
Array ( [1] => 2 [hello] => 2 [world] => 1 )
count()
These function is very common & its return total amount of value
from array .
<?php $array = array("a" => "green", "b" => "brown", "c" => "blue", "red"); echo count($array); ?>
4
Thanks
Top comments (0)