Jump to content

[SOLVED] Code Snippet To List Directory Contents -- Need Help Displaying Data


mcubedma

Recommended Posts

Hello.  I've used this code snippet to list directory contents, but it lists the contents in a line without blanks.  For example,

List of files:

 

Autumn Leaves.jpgCreek.jpgDesert Landscape.jpgphpshow.phpindex.phpfilelist.php

 

I'd like to have a line break between file names.  Can anyone help me with this?

 

<?php
if ($handle = opendir(' . ')) {
   while (false !== ($file = readdir($handle)))
      {
          if ($file != "." && $file != "..")
          {
                  $thelist .= '<a href="'.$file.'">'.$file.'</a>';
          }
       }
  closedir($handle);
  }
?>
<P>List of files:</p>
<P><?=$thelist?></p>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.