Core Function StrCmp
StrCmp( <str1>, <str2>, <ignoreCase>, <start>, <length> )
Contents |
Description
String comparison.
Used to compare if two strings are equal/lesser or greater.
Parameters
str1
The first string.
str2
The second string.
ignoreCase
Optional; Do case insensitive match
true = Ignore case and match case insensitively
false = Case must be an exact match
Default: false
start
Optional; The starting position of the search.
OR
If the start is a negative value the character position will work backwards from the length of the string.
Default: 0
length
Optional; The number of characters to search. By default the entire remainder of the string.
If length is given and is negative, then that many characters will be omitted from the end of string (after the start position has been calculated when a start is negative). If start denotes the position of this truncation or beyond, -1 will be returned.
Return Value
-1 if str1 is less than str2
1 if str1 is greater than str2
0 if they are equal.
Remarks
None.
Example
echo (StrCmp("Hello", "Hello") . "\n"); echo (StrCmp("Hello", "HellO") . "\n"); echo (StrCmp("Hello", "HellO", true) . "\n"); echo (StrCmp("HellO", "Hello") . "\n"); echo (StrCmp("HellO", "Hello", true) . "\n"); /* 0 -1 0 1 0 */