From the course: Learning the Standard PHP Library
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Filtering a directory with GlobIterator - PHP Tutorial
From the course: Learning the Standard PHP Library
Filtering a directory with GlobIterator
- When traversing the file system, you're often interested only in certain types of files. In the previous chapter, we used a conditional statement to find the file name extension, but there's a more direct way to filter files by globbing. If you're not familiar with the expression, globbing means matching file names with wildcard characters or glob patterns. These are the main patterns used by PHP. A question mark matches a single character. An asterisk matches zero or more characters, but not in the same way as in a regular expression. It doesn't mean repeat the previous character zero or more times. It simply means any characters or none at all. A group of characters inside square brackets matches a single character from that group. You can also specify a range of characters inside square brackets by separating them with a hyphen. The example shown here means match a single number in the range from three to seven inclusive. An exclamation mark at the beginning of a group or range…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Filtering a directory with GlobIterator5m 14s
-
(Locked)
Using regular expressions to filter directories with RegexIterator3m 49s
-
(Locked)
Extracting data from XML with RegexIterator and SimpleXML6m 25s
-
(Locked)
Specifying a range of items with LimitIterator4m 21s
-
(Locked)
Creating a custom filter with CallbackFilterIterator5m 6s
-
(Locked)
Creating a recursive callback filter5m 42s
-
(Locked)
Extending FilterIterator to create a reusable filter5m 10s
-
(Locked)
Creating a custom filter with RecursiveFilterIterator4m 48s
-
(Locked)
Overriding the RecursiveFilterIterator constructor5m 16s
-
(Locked)
Using ParentIterator to find elements that have children3m 59s
-
(Locked)
-
-
-
-
-