467,104 Members | 1,025 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,104 developers. It's quick & easy.

Directory Listing ...

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
  • viewed: 2030
Share:
3 Replies
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
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
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.

Similar topics

19 posts views Thread by SU News Server | last post: by
2 posts views Thread by Tom | last post: by
8 posts views Thread by gil | last post: by
2 posts views Thread by ngr | last post: by
8 posts views Thread by dougawells@gmail.com | last post: by
4 posts views Thread by techusky@gmail.com | last post: by
2 posts views Thread by marcusadeleon@gmail.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.