Alejandro Gervasio says that the DirectoryIterator class is an important part of the Standard PHP Library (SPL). Among other things, it lets you traverse any specified directory with a regular 'foreach' loop. In the first article of a three-part series, some of the methods that come with the 'DirectoryIterator' class are covered.
According to Gervasio, the class might be handy to use in projects where handling directories is a must. In the new series he’ll be taking a close look at some of its important methods. He explores the methods appropriately in conjunction with the corresponding code samples.
Gervasio begins the article with the main methods of the DirectoryIterator class in PHP 5. He explains why you should use the DirectoryIterator class and examines examples. He demonstrates a standard way to traverse directories using the DirectoryIterator class. Gervasio also delves deeper into the DirectoryIterator class using the key() and current() methods. He concludes the article by resetting a directory’s internal pointer or the rewind() method.





