count, count ignore zero, count ignore blanks, count ignore both
These functions counts number of affected parameters.
The suffix ... ignore zero excludes all zero values: Numeral 0, Boolean false and blank dates.
The suffix ... ignore blanks excludes all strings with blank values: String blank (0 characters), blank dates and empty sets in sets (but includes sets containing something, including nested empty sets).
The suffix ... ignore both covers both of the above.
Please note that equivalent conditional combination functions are also available for the function names listed above which allows
you to pre-select specific parameters to include in the calculation using one or more comparisons .
Min 1
No. | Type | Description |
---|---|---|
1, etc. input |
valid types | All function parameters: Same parameter passing principle is applied like other series functions such as add(), sub(), etc. |
Type | Description |
---|---|
numeral | Result Calculated value |
Function names containing 'numeral' assert exceptions if values provided are not of type numeral.
echo( count ( 1, 2, 3, a, '', ' ',0 ) ); // 7
echo( count ignore zero ( 1, 2, 3, a, '', ' ',0 ) ); // 6
echo( count ignore blanks( 1, 2, 3, a, '', ' ',0 ) ); // 5 (only pure blank ignored)
echo( count ignore both ( 1, 2, 3, a, '', ' ',0 ) ); // 4 (both 0 and blank ignored)
echo( count ( date(today), date(""), true, false ) ); // 4
echo( count ignore zero ( date(today), date(""), true, false ) ); // 2 (blank date, false)
echo( count ignore blanks( date(today), date(""), true, false ) ); // 3 (blank date)
echo( count ignore both ( date(today), date(""), true, false ) ); // 2 (both)
7
6
5
4
4
2
3
2
counting set elements with {}