echo substr_compare("abc", "abc", 0); // 0, similar to strcmp
echo substr_compare("bbc", "abc", 0); // 1, similar to strcmp
echo substr_compare("abcd", "abc", 0); // 1, similar to strcmp
echo substr_compare("abc", "abcd", 0); // -1, similar to strcmp
echo substr_compare("abc", "bbc", 0); // -1, similar to strcmp
//If length is specified, that specified length of substr and mainstr is compared, the other chars are ignored
echo substr_compare("abc", "abcd", 0 , 3); // 0
//If specified length is more than the subsring but subsring is matched with the part of the
//mainstr, so ramining length of subsring is printed
echo substr_compare("abcdefgh", "abc", 0 , 6); // 3
\http://www.w3schools.com/php/func_string_substr_compare.asp
offset theke suru kore length porjonto main string er sathe subsring er tulona kora hoi.
<?phpecho substr_compare("abcde", "bc", 1, 2); // 0echo substr_compare("abcde", "de", -2, 2); // 0echo substr_compare("abcde", "bcg", 1, 2); // 0echo substr_compare("abcde", "BC", 1, 2, true); // 0echo substr_compare("abcde", "bc", 1, 3); // 1
//echo substr_compare("abcde", "cd", 1, 2); // -1
// cd ar offset deo offset chea basiecho substr_compare("abcde", "abc", 5, 1); // warning?>
No comments:
Post a Comment