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.
Inspecting single directories with FilesystemIterator - PHP Tutorial
From the course: Learning the Standard PHP Library
Inspecting single directories with FilesystemIterator
- FilesystemIterator extends DirectoryIterator, so it's quite similar but it adds a number of improvements. I've copied filesystem.php from the Chapter 2 folder of the exercise files, and I've adjusted the path to the Common Images directory. Although we're going to be looking at FilesystemIterator, I'm going to begin with DirectoryIterator so we can see what the difference is. So let's load this page into a browser. We're not filtering out the files, so we've got also the dot files that represent the current and parent directories. And then we've got the names of all the files in the Images folder. So let's see what happens when we change that to FilesystemIterator. So if we just save that, and then refresh the browser. The dot files have gone, and instead of just the filename, we've got the relative path followed by the filename. Another important difference is that FilesystemIterator uses the path as the key, whereas DirectoryIterator uses a number. So let's just see that. So if we…
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
-
-
-
-
Inspecting single directories with DirectoryIterator6m 52s
-
(Locked)
Inspecting single directories with FilesystemIterator5m 59s
-
(Locked)
Inspecting directories recursively with RecursiveDirectoryIterator6m 58s
-
(Locked)
Getting information about files with SplFileInfo5m 34s
-
(Locked)
Working on text files with SplFileObject8m
-
(Locked)
Using SplFileObject to convert a CSV to an array4m 25s
-
(Locked)
Exporting data to a download file with SplTempFileObject5m 24s
-
-
-
-
-
-
-