compare
This function performs a comparing between 1st parameter (a value) and 2nd parameter containing a code piece or string containing the comparison expression.
Indirect parameter passing is disabled
2
No. | Type | Description |
---|---|---|
1 input |
all types | Value to compare This value will be compared with the comparison expression in the 2nd function parameter. |
2 code |
comparison expression :string |
Comparison expression This parameter is a piece of code typically found on the right-hand side of a comparison with '=' or '<>'. Single values, ranges (e.g. 3..5), multiple values separated by commas are supported. For text comparison, wildcards are supported if the string is of type softquoted string. |
Type | Description |
---|---|
boolean | Comparison result |
a[] = 3; b[] = 5; c[] = 7;
ex[] = ">6";
echo("Greater than 4: ", compare( a[], >4 ), " ", compare( b[], >4 ), " ", compare( c[], >4 ) );
echo("Greater than 6: ", compare( a[],:ex[]), " ", compare( b[],:ex[]), " ", compare( c[],:ex[]) );
// Note the required colon. Otherwise ex[] is seen as variable to compare with.
Greater than 4: false true true
Greater than 6: false false true