count elements, count elements ignore case, count elements ignore blanks, count elements ignore both
Counts the number of elements which match with the supplied value. The ordering of the elements in the sets do not matter.
Attention: Comparing Boolean true and string 'true' (lower case letters) will also count because comparison is based on
the single '=' comparison operator which returns true if true = "true" and vice versa.
Indirect parameter passing is disabled
2
No. | Type | Description |
---|---|---|
1 input |
set or string | input set If provided as a set: Will be used for counting elements |
2 input |
valid types | matching value The comparison looks into both value and type. Providing a numeral 1 is not the same as a string '1'.
The set will be compared with this value in order to count matches.
The options 'ignore case', 'ignore blanks' and both combined will only apply if the values compared are strings. |
Type | Description |
---|---|
numeral | Number of elements identified Number of elements (nested elements are not counted) |
print ( count elements( { Amy, Amsel, Bea, Beat, Charles, Charly }, 'Am*' ),", " ); // 2
print( count elements( { Amy, Amsel, Bea, Beat, Charles, Charly }, "Am*" ), ", " ); // 0
echo ( count elements ignore case( { Amy, Amsel, Bea, Beat, Charles, Charly }, amsel ) ); // 1
print ( count elements( { 1, true, false, true, 2 }, true ), ", " ); // 2
print ( count elements( { 1, true, false, true, 2 }, "true" ), ", " ); // 2 (true = 'true') case
echo( count elements( { 1, '1', 2, '2' }, 'true' ) ); // 0
// Subsets
print( count elements( { a,b,c,{d,e} }, {d,e} ), ", " ); // 1
echo( count elements( { a,b,c,{d,e} }, {e,d} ) ); // 1
2, 0, 1
2, 2, 0
1, 1