title: PHP - returning closest match from database
body: <p>I'm returning mobile phone data based on the user agent. But in an instance where the useragent is not stored (newer version of phone or software) I want to be able to return the closest match, a bit like how Google displays the "did you mean this". i.e.</p>
  
  <p>if I have a stored useragent of </p>
  
  <blockquote>
    <p>Mozilla/5.0 (Linux; U; Android
    2.1-update1; en-nl; Desire_A8181 Build/ERE27) AppleWebKit/530.17
    (KHTML, like Gecko) Version/4.0 Mobile
    Safari/530.17</p>
  </blockquote>
  
  <p>and the user agent in use is </p>
  
  <blockquote>
    <p>Mozilla/5.0 (Linux; U; Android
    2.1-update1; en-nl; Desire_G45H Build/ERE27) AppleWebKit/530.17
    (KHTML, like Gecko) Version/4.0 Mobile
    Safari/530.17</p>
  </blockquote>
  
  <p>I want to be able to return the one stored to add or adapt my data accordingly.</p>
  
  <p>Does anyone know a way of achieving this?</p>