RE: [PHP] Listing the contents of a directory in an array

From: Date: Fri, 17 May 2002 13:28:17 +0000
Subject: RE: [PHP] Listing the contents of a directory in an array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-98077@lists.php.net to get a copy of this message
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: webmaster@tececo.com [mailto:webmaster@tececo.com] Sent: Friday, May 17, 2002 8:31 AM To: php-general@lists.php.net 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 webmaster@tececo.com www.tececo.com

« previous php.general (#98077) next »