title: PHP For Loop Directory Listing Doesn't Make Links
body: <p>I have been trying to make a simple php application which reads a directory of images and folders possibly containing other folders and images. Basically it is supposed to read the directory, and then pass on the list to a javascript array which would then show the links to images/directories in a much nicer way (preview and other nice things). This is supposed to be a simple, pretty interface but at this point, I can't even get the php directory reading to work properly.</p>
  
  <p>I currently have the following code:</p>
  
  <pre><code>&lt;?php
  $dir    = $_SERVER["DOCUMENT_ROOT"] . '/';
  $files = scandir($dir);
  
  for ($x = 0; $x &lt;= 10; $x++) {
     echo "&lt;href src='/" . $files[$x] . "'&gt;" . $files[$x] . "&lt;/href&gt;&lt;br&gt;";
  }
  ?&gt;
  </code></pre>
  
  <p>When this code runs, it prints out something like this:</p>
  
  <pre><code>.
  ..
  Directory/File name 1
  Directory/File name 2
  Directory/File name 3
  And so on
  </code></pre>
  
  <p>What it is supposed to do is print out all the files and make them into a link to the proper page. What it is doing is exactly that with one exception. When it prints out, I cant click any of the links nor are they blue like they should be. If I inspect element and look at the source, it shows the links properly inserted into the page yet they don't show as links.</p>
  
  <p>This is my main problem right now along with the one dot and the two dots. I am a PHP newbie and have no idea how to get rid of these. I also cant make it not limited to 10 items in the for loop. I have no idea on how to fix any of these issues and I would really appreciate any help on this or maybe just a push in the right direction.</p>
  
  <p>Thanks in advance,
  Emanuel</p>