substr_compare()

It compares two strings from a specified start position

This function returns:
0 – if the two strings are equal
<0 – if string1 (from startpos) is less than string2
>0 – if string1 (from startpos) is greater than string2
If length is equal or greater than length of string1, this function returns FALSE

Example

<?php
 echo substr_compare("phpcodexc","phpcode",0);
 ?>

Output

2

Share