The general approach is like this:
Copy the codeThe code is as follows:
for ($offset = 0; $offset < $length; ++$offset) {
if ($str1[$offset] !== $str2[$offset]) {
return $offset;
}
}
The best answer given below is to use the XOR operator (^). I have never used this operator before, and I don’t know where it can be used. Today It's learned.
Because generally, when you perform an XOR operation on two strings, the XOR result of the same characters is null("
http://www.bkjia.com/PHPjc/750855.htmlwww.bkjia.com
true
http: //www.bkjia.com/PHPjc/750855.html
TechArticle
The general approach is like this: Copy the code as follows: ?php for ($offset = 0; $offset $ length; ++$offset) { if ($str1[$offset] !== $str2[$offset]) { return $offset; } } And the question...