Re: Getting the filenames from a folder
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Re: Getting the filenames from a folder

From: Andy Hassall <andy@andyh.co.uk>
Date: Sun Oct 30 2005 - 16:29:18 CET

On Sun, 30 Oct 2005 15:10:42 -0000, Krustov <krusty@krustov.co.uk.INVALID>
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@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Received on Mon Nov 21 02:53:02 2005