title: PHP - Sorting directory alphabetically on drop down list
body: <p>How would I sort the directory to display the drop down list alphabetically?</p>
  
  <pre><code>&lt;select name=country&gt;
  &lt;?php
  $handle=opendir("images/flags");
  while (false!==($file = readdir($handle))) { 
    if ($file != "." &amp;&amp; $file != "..") { 
      $country = substr($file,0,strpos($file,'.'));
      echo "&lt;option value=\"".$file."\"&gt;&lt;center&gt;".$country."&lt;/center&gt;&lt;/option&gt;\n";
    } 
  }
  closedir($handle);
  ?&gt;
  &lt;/select&gt;
  </code></pre>