subset, subset ignore case, subset ignore blanks, subset ignore both, subset recursive, subset recursive ignore case, subset recursive ignore blanks, subset recursive ignore both
This function checks whether the set in the 2nd function parameter is a subset of the 1st set.
The recursive will also include the nested sets into subset checking, e.g. subset( {{a,b,c},c,d}, {{a,b},d} ) is true. Otherwise, {a,b,c} and {a,b} ares treated as different elements.
Counts the number of elements which match with the supplied value.
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 | subset to check If provided as a set: Will be used for counting elements |
Type | Description |
---|---|
boolean | 2nd set is a subset of 1st set Number of elements (nested elements are not counted) |
a[] = { a, b, c, {d, e}, f, {} };
echo ( subset( a[], {} ) ); // True (Empty set is always subset)
print( subset ( a[], {A} ), ", " ); // False (A is not in the set)
echo ( subset ignore case( a[], {B,A} ) ); // True (cases ignored)
print( subset( a[], {c,{},f} ), ", " ); // True (Empty set is always subset)
print( subset( a[], {f,{d,e}} ), ", " ); // True (Empty set is always subset)
print( subset( a[], {f,{e,d}} ), ", " ); // False. {e,d} not equal to {d,e}
echo ( subset recursive( a[], {{d,e}} ) ); // True. {e,d} not equal to {d,e}
true
false, true
true, true, false, true