PDA

View Full Version : Problem gettings the files of a directory in PHP



Owen
April 17th, 2001, 16:47
I am making a mailing list program to get some PHP programming exprience. However, I have debugged every problem that has come up in my scripts except one.

CODE :

<?
//Gets all the different mailing lists
opendir($listdir);
$lists = dir($listdir);
?>

I am trying to get all of the files inside the directory(which is $listdir). I have placed a file inside the directory for the lists, however, the program can not seem to get the files.

There is no error of the PHP programming itself, because when I run the program, everything runs fine, except for getting the text files.

What am I doing wrong here. I probably am so tired of debugging the script I am missing it.

keith
April 17th, 2001, 22:43
<?
$dir="directory_name"; // directory to index
$a=opendir($dir);
while($b=readdir($a))
{
if(ereg("^\.",$b)) continue;
echo "<a href=$b>$b</a><br>";
}
closedir($a);
?>