title: Showing files that aren't there
body: <p>I've finally found a way to get all the files from a folder to display on the site but for some reason it always displays 3 Div's that are empty and i really mean empty not some dots like in this post: </p>
  
  <p><a href="https://stackoverflow.com/questions/36907031/php-scandir-produces-extra-elements-2-dots">php scandir produces extra elements (2 dots)</a> </p>
  
  <p>Even without having any files in the folder. As seen on the picture</p>
  
  <p><a href="https://i.stack.imgur.com/Hxneb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Hxneb.png" alt="enter image description here"></a></p>
  
  <p>Does anyone have an idea why it behaves this way? I've included the code snippet that is causing the issue i think.</p>
  
  <pre><code>&lt;div class="margin"&gt;
      &lt;div class="left js-equal-height" &gt;
          &lt;h2&gt;Recent nieuws&lt;/h2&gt;
                  &lt;?php
      $dir = 'Nieuws';
      $file_display = ['txt'];
      $value = 0;
      if (file_exists($dir) == false) {
          return ["Directory \'', $dir, '\' not found!"];
      } else {
          $dir_contents = scandir($dir);
          foreach ($dir_contents as $file) {
  
          $img = basename($file, ".txt") . ".png";
          $src = 'Nieuws/pics/'.$img;
  
          echo '&lt;div class="frontNieuws"&gt;';
  
  
          if (@getimagesize($src)) {
              echo '&lt;img class="nieuwsFoto" 
                src="Nieuws\pics\\' . $img . '" alt="Nieuwsfoto"&gt;';
          } else {
              echo '&lt;img class="nieuwsFoto" 
                src="Nieuws\pics\default.png" alt="Nieuwsfoto"&gt;';
          }
          echo file_get_contents($dir . '/'. $file, 
                        false, null, 0, 200) . " ... Lees meer!";
          echo '&lt;/div&gt;';
          }
      }
  
    ?&gt;
  </code></pre>
  
  <p></p>