title: return string most like another string in PHP
body: <p>I'm trying to build a spell checking system in PHP.</p>
  
  <p>I already have a lexicon / corpus of many of the words in the English language. Each word on a new line.</p>
  
  <p>What I'm trying to do is once given a string, let's call it $string1, open the text file and search it for the string most like $string1 and return that string.</p>
  
  <p>For the searching the text file, my idea is to import the contents into an array and then use in_array(). If there is a better way to search the text file without importing all the words into the memory, please let me know.</p>
  
  <p>I don't know how to compare the two strings for similarities. How would I do that?</p>
  
  <p>In my mind, all the same letters but in a different order would rank higher than different letters. But what would rank higher than both would be a partial match +/- a character or two.</p>
  
  <p>I would greatly appreciate any help with opening the text file and searching it and comparing the strings.</p>