Connecting Tech Pros Worldwide Forums | Help | Site Map

Directory Listing ...

Alan Searle
Guest
 
Posts: n/a
#1: Jul 17 '05
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

a@b.c
Guest
 
Posts: n/a
#2: Jul 17 '05

re: Directory Listing ...


Alan Searle wrote:[color=blue]
> 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[/color]

http://www.php.net/dir
Andreas Baumgart
Guest
 
Posts: n/a
#3: Jul 17 '05

re: Directory Listing ...


On Wed, 30 Jun 2004 11:52:18 -0400
Alan Searle <aj_searle@xxxxyahoo.com> wrote:[color=blue]
> 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).[/color]

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 andreas@slashdot.ch
tcp/6667 irc.slashdot.ch #garbage
Tim Van Wassenhove
Guest
 
Posts: n/a
#4: Jul 17 '05

re: Directory Listing ...


In article <cbu2pm$ho4$1@newsreader2.netcologne.de>, Alan Searle wrote:[color=blue]
> 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.[/color]

It's in the http://www.php.net/manual.
[color=blue]
> Can someone send me a snippet of syntax? Or point me towards a good
> 'howto' that maybe has a catalogue of PHP commands?[/color]

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>
Closed Thread