Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

String similarity

Name: Anonymous 2010-09-08 4:41

PHP has a function that does it. How would I implement it? Considering string shifting and single character differences, that's a lot of cases to go through.

Name: Anonymous 2010-09-08 17:42


function similarity($a, $b) {
  $similarity = 0;
  for ($i=0; i < strlen($a); $i++) {
    if ($a[$i] == $b[$i])
      similarity++;
    else
      similarity--;
  }
  return $similiarity / strlen($a);
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List