Re: Getting the filenames from a folder
- From: Andy Hassall <andy@xxxxxxxxxxx>
- Date: Sun, 30 Oct 2005 15:29:18 +0000
On Sun, 30 Oct 2005 15:10:42 -0000, Krustov <krusty@xxxxxxxxxxxxxxxxxxxxx>
wrote:
><?php
>$dirname = ".";
>$dh = opendir($dirname);
>while ($file = readdir($dh))
>{
>if (is_dir ("$dirname/$file"))
>{
>print "";
>}
>print "$file<br>";
>}
>closedir ($dh);
>?>
>.
>..
>aaa.html
>etc
>
>The above code brings up the single and twin full stops - presumably the
>option to change directorys or whatever if wanted .
>
>Got the code snippet via google and just wondered if the above code is
>the best way it could be written .
See the example in the manual, it's superior in a couple of ways.
http://uk.php.net/opendir
For example, consider the behaviour of the code you posted in the presence of
files or directories named "0".
--
Andy Hassall :: andy@xxxxxxxxxxx :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
.
- Prev by Date: Re: Question on PhP, MySQL
- Next by Date: PHP & TPL files
- Previous by thread: Removing quotes from an array, string or txt file see code
- Next by thread: Re: Getting the filenames from a folder
- Index(es):