faqts : Computers : Programming : Languages : PHP : Common Problems : Files

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

3 of 5 people (60%) answered Yes
Recently 3 of 5 people (60%) answered Yes

Entry

How can I dir a folder and return the files in it as an array?

Feb 9th, 2004 12:18
Brett Christiansen, Pablo Karlsson,


To get the directories contents into an array, you could probably make 
use of the readdir() function.  For info on its use try 
http://us4.php.net/readdir  you'll need to open the directory of 
course and use a loope to add each file name into your array, there is 
also some sample code at the above link that loops to print the 
contents so you could easily modify that to add the name to an array 
rather than print it out. Hope this helps.