I'm the same way as NogDog right now...
function compareProteinStrings($str1, $str2)
{
static $mapping = null;
if(!isset($mapping))
{
$mapping = array_fill_keys(array_map('chr', range(1,255)), '0');
$mapping[chr(0)] = '1';
}
if(strlen($str1) != strlen($str2))
{
throw new Exception("Strings are not the same length");
}
return strtr($str1 ^ $str2, $mapping);
}
In passing, the [man]levenshtein[/man] function can be used to measure the edit distance between two strings.