By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,722 Members | 1,904 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,722 IT Pros & Developers. It's quick & easy.

Directory Listing ...

P: n/a
I'm a newbie to PHP and need to be able to get a list of the
files/sub-directories from a particular directory on the server (ie: I
want to load the list of files in the program's current directory into
an array).

This must be possible but somehow I can't find the syntax in my
documentation.

Can someone send me a snippet of syntax? Or point me towards a good
'howto' that maybe has a catalogue of PHP commands?

That would be a great help.

Many thanks,
Alan Searle
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
a
Alan Searle wrote:
I'm a newbie to PHP and need to be able to get a list of the
files/sub-directories from a particular directory on the server (ie: I
want to load the list of files in the program's current directory into
an array).

This must be possible but somehow I can't find the syntax in my
documentation.

Can someone send me a snippet of syntax? Or point me towards a good
'howto' that maybe has a catalogue of PHP commands?

That would be a great help.

Many thanks,
Alan Searle


http://www.php.net/dir
Jul 17 '05 #2

P: n/a
On Wed, 30 Jun 2004 11:52:18 -0400
Alan Searle <aj*******@xxxxyahoo.com> wrote:
I'm a newbie to PHP and need to be able to get a list of the
files/sub-directories from a particular directory on the server (ie: I

want to load the list of files in the program's current directory into
an array).


You can scan a directory with

$handle = opendir("somedirectory");
while($filename = readdir($handle))
$fileslist[] = $filename;
closedir($handle);

In PHP5 there seems to be a single function scandir() which does
exactly what you want.

Greets,
Andreas

--
tcp/80 http://andreas.slashdot.ch
tcp/25 an*****@slashdot.ch
tcp/6667 irc.slashdot.ch #garbage
Jul 17 '05 #3

P: n/a
In article <cb**********@newsreader2.netcologne.de>, Alan Searle wrote:
I'm a newbie to PHP and need to be able to get a list of the
files/sub-directories from a particular directory on the server (ie: I
want to load the list of files in the program's current directory into
an array).

This must be possible but somehow I can't find the syntax in my
documentation.
It's in the http://www.php.net/manual.
Can someone send me a snippet of syntax? Or point me towards a good
'howto' that maybe has a catalogue of PHP commands?


Have a look in the archives of this group. It has been posted here this
week already. And probably many times before...

--
Tim Van Wassenhove <http://home.mysth.be/~timvw>
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.