Example
Compare two Strings:
<?php echo substr_compare("Hello world","Hello world",0); ?>
Definition and usage
substr_compare() function compares two strings from the specified starting position string.
Tip: This function is binary safe and optionally case sensitive.
Syntax
substr_compare(string1,string2,startpos,length,case)
Parameters | Description |
string1 | Required. Specifies the first string to compare. |
string2 | Required. Specifies the second string to be compared. |
startpos | Required. Specifies where in string1 to begin comparison. If negative, counting starts from the end of the string. |
length | Optional. Specifies the number of characters in string1 to be compared. |
case | Optional. A Boolean value that specifies whether to perform case-sensitive comparisons:
|
Technical Details
Return value: | This function returns:
|
PHP Version: | 5+ |
##Update Log : | As of PHP 5.1, negative startpos is allowed.