Method Array.count()
- Method
count
int
count(array
|mapping
|multiset
haystack
,mixed
needle
)
mapping
(mixed
:int
) count(array
|mapping
|multiset
haystack
)- Description
Returns the number of occurrences of
needle
inhaystack
. If the optionalneedle
argument is omitted, count instead works similar to the unix command sort|uniq -c, returning a mapping with the number of occurrences of each element inhaystack
. For array or mappinghaystack
s, it's the values that are counted, for multisets the indices, as you'd expect.- See also