|
Posted by Andy Hassall on 10/30/05 17:29
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
Navigation:
[Reply to this message]
|