Home arrow PHP arrow Finding Paths, Timestamps and More with the DirectoryIterator Class in PHP

Finding Paths, Timestamps and More with the DirectoryIterator Class in PHP

Are you interested in having at your disposal a quick reference for working with the “DirectoryIterator” class that comes with PHP 5? Then this might be the article that you’ve been waiting for! Welcome to the second tutorial of the series “A Close Look at the DirectoryIterator Class in PHP 5.” Over the course of this set of installments, you’ll find complete coverage of the most important methods bundled with this class, and learn how to take advantage of their excellent functionality.

TABLE OF CONTENTS:
  1. Finding Paths, Timestamps and More with the DirectoryIterator Class in PHP
  2. Learning the rewind(), current() and valid() methods
  3. Using the getFileName() and isFile() methods
  4. Using the getMTime(), getATime(), and getCTime() methods
  5. Using the getPath() and getPathName() methods
By: Alejandro Gervasio
Rating: starstarstarstarstar / 5
September 18, 2006

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Introduction

If you’ve read the previous article, you probably have a better idea now of how the “DirectoryIterator” class does its business. As you’ll certainly remember, all the code samples that were shown in that article were aimed at demonstrating how easy this class makes it to traverse a specified directory.

Having at hand such a useful piece of code, there’s no need to create custom classes to deal with the contents of any directory, since the mentioned class can traverse a directory by using a regular “foreach” loop. In addition, the class on its own comes packaged with a bunch of handy methods which can be used for moving the iterator’s pointer back and forward,  as well as obtaining complete information on the size, type, paths, etc. of the files contained within the selected directory.

If the wealth of impressive features exposed by this class isn’t enough for you, I have still more material to show you in the next few lines. Now that I have your attention, in this second part of the series I’ll continue exploring new methods that come with the “DirectoryIterator” class, including those that use additional capabilities to determine the full path and name of directory elements, their modification timestamps, and much more.

Having established the goals of this article, it’s time to jump forward and keep learning more about the “DirectoryIterator” class. Let’s get going!



 
 
>>> More PHP Articles          >>> More By Alejandro Gervasio
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: