From the course: PHP Techniques: Working with Files and Directories
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Skipping directory entries - PHP Tutorial
From the course: PHP Techniques: Working with Files and Directories
Skipping directory entries
- [Instructor] One common question is how to skip over directory entries especially since every directory contains entries for the.and.dot at the start. One easy way to skip entries in PHP is to write a conditional statement inside the loop, which calls continue. If the Boolean expression evaluates to true continue tells PHP to ignore everything else in the loop, and immediately jump to the next iteration. In our dir access dot PHP page. Let's add some code to skip some of the entries. Right here, we'll put in code that says, skip the.and.dot files and we'll do that with if and then a Boolean expression and then continue. So what should our Boolean expression be? Well, if entry is equal to a dot or if entry is equal to.dot, then skip over it. Let's save it. We'll go back to Firefox or reload this page. You can see now it skipped over.and.dot or we could skip over all dot files,…