I actaully had to do that yesterday, here is the code i used.
$path = "/foo/bar";
$myArray = $array();
$dir = opendir($path);
while($file = readdir($dir)) {
// if(!ereg("^\.", $file) {
$myArray[count($myArray)] = $file;
// }
}
closedir($dir);
If you want to exclude the always present "." and ".." directories just
uncomment those two lines.
-Jared
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 17, 2002 8:31 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Listing the contents of a directory in an array
I am a newbie so be kind
I have looked into the manual about directory functions etc.
I want to return all the files from a directory into a array.
Could some one give me a few pointers or something?
I keep getting confused but I have used google and the manual.
I can find functions but I am not sure how I can list the files into an
array.
Thanks in advance,
JJ Harrison
[EMAIL PROTECTED]
www.tececo.com