Extracted from Pike v7.3 release 45 at 2002-06-04.
pike.roxen.com
[Top]
Array

Method Array.count()


Method count

int Array.count(array|mapping|multiset haystack, mixed needle)
mapping(mixed:int) Array.count(array|mapping|multiset haystack)

Description

Returns the number of occurrences of needle in haystack. If the optional needle argument is omitted, Array.count instead works similar to the unix command sort|uniq -c, returning a mapping with the number of occurrences of each element in haystack. For array or mapping haystacks, it's the values that are counted, for multisets the indices, as you'd expect.

See also

String.count, search, has_value