title: PHP: How to list files in a directory without listing subdirectories
body: <p>This is the starting portion of my code to list files in a directory:</p>
  
  <pre><code>$files = scandir($dir); 
  $array = array(); 
  foreach($files as $file)
  {
      if($file != '.' &amp;&amp; $file != '..' &amp;&amp; !is_dir($file)){
            ....
  </code></pre>
  
  <p>I'm trying to list all files in a directory without listing subfolders. The code is working, but showing both files and folders. I added <code>!is_dir($file)</code> as you see in my code above, but the results are still the same.</p>