title: Pull images from album & display them
body: <pre><code>&lt;?php
  //access the directory
  $dir = dir('pics');
  
  //build array of files in the directory
  while (($pic = @$dir-&gt;read()) !== FALSE){
      $pics [$pic]= filesize('pics/'.$pic);
  }
  
  asort ($pics);
  
  $txtfile=@fopen('txtfile.txt', 'w');
  
  if ($txtfile === NULL) {
      throw new FileOpenException('txtfile.txt');
      //loop though and print each file as a link
      foreach ($pics as $name =&gt; $filesize){
          if ($name !="." &amp;&amp; $name !=".."){
              echo "$filesize bytes &lt;img src='pics/".$name."'/&gt;&lt;br&gt;";
              $result =@fwrite($txtfile, $name . "\r\n");
              if ($result === FALSE)
                  throw new FileWriteException();
              }
      }
  }
  
  fclose($txtfile);
  
  ?&gt;
  </code></pre>
  
  <p>This code snippet was given by a professor to use for a project we are working on but it is not working &amp; prof doesn't seem to know much. </p>
  
  <p>The codes is meant to pull images from an album and display them but nothing I do seems to work. The album is named pics and is in the same folder as everything else. </p>
  
  <p>Any help is appreciated.</p>