Jump to content

PHP help needed - directory listing problem


hitchhiker

Recommended Posts

Hi,

 

I'm using the following code to list the files in a directory. The problem is that besides the correct files it also returns two extra files named '.' and '..'!

 

This is the code:

 

<?php

$direct = "image/";

if ($handle = opendir('images/')) {
   while (false !== ($file = readdir($handle))) {
         echo ("<p>" . $file . "</p>");
           }
  closedir($handle);
}
?> 

 

And it returns this:

 

.

..

image1.gif

image2.gif etc.

 

I can't understand what the '.' and '..' are there for as they are not in the actual directory on the server?

 

Also, if there's nothing I can do about this, how would I get round it i.e. ignore anything found called '.' or '..'.

Link to comment
Share on other sites

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.