title: Why isn't natsort (or natcasesort) working here?
body: <p>Perhaps I'm doing something embarrassingly wrong, but why isn't this array being sorted?</p>
  
  <pre><code>$narray=array();
  
  $dir_handle = @opendir($path.$projectFolder) or die("Unable to open $path$projectFolder");
  
  $i=0;
  
  while($file = readdir($dir_handle)) {
  
   $filenameSplit = explode('.',$file);
  
   if ($file != "." &amp;&amp; $file != ".." &amp;&amp; $filenameSplit[0] != "logo" &amp;&amp; $filenameSplit[1] != "zip" &amp;&amp; $filenameSplit[1] != "pdf" &amp;&amp; $filenameSplit[1] != "doc" &amp;&amp; $filenameSplit[1] != "psd" &amp;&amp; $filenameSplit[1] != "") {
  
    $narray[$i]=$file;
  
    $i++;
   }
  
  }
  
  natcasesort($narray);
  </code></pre>
  
  <p>I seem to be getting the same results I get when I don't attempt to sort the array at all. <code>sort()</code> works, but nothing else seems to.</p>
  
  <p>Thanks for any help!</p>
  
  <hr>
  
  <p>Update: </p>
  
  <p>Here are sample results:</p>
  
  <p>With <em>no sort</em>:</p>
  
  <pre><code>03_piper_file-manager_02.jpg
  05_piper_login-page_02.jpg
  02_piper_file-manager_no-slides_01.jpg
  04_piper_file-manager_02.jpg
  01_piper_file-manager_no-slides_01.jpg
  </code></pre>
  
  <p>With <code>sort()</code>:</p>
  
  <pre><code>01_piper_file-manager_no-slides_01.jpg
  02_piper_file-manager_no-slides_01.jpg
  03_piper_file-manager_02.jpg
  04_piper_file-manager_02.jpg
  05_piper_login-page_02.jpg
  </code></pre>
  
  <p>With <code>natsort()</code> or <code>natcasesort()</code>:</p>
  
  <pre><code>03_piper_file-manager_02.jpg
  05_piper_login-page_02.jpg
  02_piper_file-manager_no-slides_01.jpg
  04_piper_file-manager_02.jpg
  01_piper_file-manager_no-slides_01.jpg
  </code></pre>
  
  <p>I expect at the very least for natsort's results to look like sort's.</p>