一般的做法就会这样:
for ($offset = 0; $offset if ($str1[$offset] !== $str2[$offset]) {
return $offset;
}
}
而问题下面给出的最佳答案是用异或操作符( ^ ),以前从来没用过这个操作符,也不知道能用到什么地方,今天算是学到。
因为一般情况下,当你对两个字符串进行异或操作的时候,相同的字符的异或结果是null(“
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn