You are here: Re: Getting the filenames from a folder « PHP Programming Language « IT news, forums, messages
Re: Getting the filenames from a folder

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация