Recipe 24.8. Getting a List of Filenames Matching a Pattern24.8.1. ProblemYou want to find all filenames 24.8.2. SolutionUse a FilterIterator subclass Using a FilterIterator
24.8.3. DiscussionThe FilterIterator encloses a DirectoryIterator and only allows certain elements to emerge. It's up to the accept( ) If your pattern can be expressed as a simple shell "glob" (e.g. *.*), use the glob( ) Using glob( )
The glob( ) function returns an array of matching full pathnames. If no files match the pattern, glob( ) returns false. 24.8.4. See AlsoRecipe 24.9 details iterating through each file in a directory recursively; documentation on FilterIterator at http://www.php.net/~helly/php/ext/spl/classFilterIterator.html and on glob( ) at http://www.php.net/glob; information about shell pattern matching is available at http://www.gnu.org/software/bash/manual/bashref.html#SEC35. |
Wednesday, January 6, 2010
Recipe 24.8. Getting a List of Filenames Matching a Pattern
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment