[thelist] PHP- get list of files in directory?

Max Schwanekamp lists at neptunewebworks.com
Tue Mar 13 13:21:05 CDT 2007


Stephen Rider wrote:
> On Mar 13, 2007, at 9:40 AM, Jay Blanchard wrote:
>> [snip]
>> Is there a way to get a list of files in a particular directory using
>> PHP?  I would preferably like to end up with an array containing the
>> name of each file found.
>> [/snip]
>> Have you Read The Fine Manual? http://www.php.net/readdir
> Didn't know what function to read up on!  PHP n00b walking, here.

If you're working in PHP5, you might use a DirectoryIterator, as it has 
lots of convenience methods like isDot() (determine if it's ./ or  ../), 
getPerms() (get file permissions) etc.

http://ramikayyali.com/archives/2005/02/25/iterators
http://us3.php.net/manual/en/ref.spl.php

-- 
Max Schwanekamp
NeptuneWebworks.com
541-255-2171




More information about the thelist mailing list