News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

JellyandCustard.com:
Using DirectoryIterator to List Files in PHP
May 23, 2006 @ 12:12:12

From JellyandCustard.com today, there's a good example of creating and using a DirectoryIterator instance to loop through the files in a directory.

During the days of PHP4, the most common way of showing the files in a directory was like so [opendir, readdir, closedir]. However, if your PHP version has now been upgraded to PHP 5, you can take advantage of DirectoryIterator instead. This class (don't get scared) is part of the SPL library that is now bundled within PHP 5.

They describe the functionality and provide a simple example of its use. Also included are the other functions you can use with the resulting file handles to make for a cleaner interface in your script. They also include two examples of its usage with the output it would give - getting some stats on selected files.

0 comments voice your opinion now!
directoryiterator standard library php5 tutorial example directoryiterator standard library php5 tutorial example


blog comments powered by Disqus

Similar Posts

NetTuts.com: So You Want to Accept Credit Cards Online?

Jan Lehnardt's Blog: Using the Zend Framework with Code Igniter (an alternative)

DevShed: Introducing Static Members and Methods in PHP 5 (Part 1)

SitePoint PHP Blog: Integrating Polymer/Dart and Symfony Part 1

DevShed: Searching and Replacing Nodes with SimpleXML in PHP 5 (Part 3)


Community Events





Don't see your event here?
Let us know!


language composer tool interview symfony artisanfiles list library podcast version community security voicesoftheelephpant framework conference introduction release laravel series opinion

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework