Wednesday, 16 March 2016

substr_compare() : compares main_str from position offset with sub_str up to length characters.

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"12); // 0echo substr_compare("abcde""de", -22); // 0echo substr_compare("abcde""bcg"12); // 0echo substr_compare("abcde""BC"12true); // 0echo substr_compare("abcde""bc"13); // 1
//echo substr_compare("abcde""cd"12); // -1
// cd ar offset deo offset chea basiecho substr_compare("abcde""abc"51); // warning?>

No comments:

Post a Comment