title: PHP/mysql array search algorithm
body: <p>I'd like to be able to use php search an array (or better yet, a column of a mysql table) for a particular string. However, my goal is for it to return the string it finds and the number of matching characters (in the right order) or some other way to see how reasonable the search results are, so then I can make use of that info to decide if I want to display the top result by default or give the user options of the top few.
  I know I can do something like</p>
  
  <pre><code>$citysearch = mysql_query("  SELECT city FROM $table WHERE city LIKE '$city' ");
  </code></pre>
  
  <p>but I can't figure out a way to determine how accurate it is.</p>
  
  <p>The goal would be:<BR>
  a) find "Milwaukee" if the search term were "milwakee" or something similar.<BR>
  b) if the search term were "west", return things like "West Bend" and "Westmont".</p>
  
  <p>Anyone know a good way to do this?</p>