How can the FilesystemIterator::SKIP_DOTS flag be effectively used to skip the . and .. entries in directory scans in PHP?
When scanning directories in PHP, the "." and ".." entries are typically included by default. To skip these entries, you can use the FilesystemIterator::SKIP_DOTS flag when creating the FilesystemIterator object. This flag will exclude the "." and ".." entries from the scan, making it easier to work with the directory contents.
$directory = new FilesystemIterator('/path/to/directory', FilesystemIterator::SKIP_DOTS);
foreach ($directory as $file) {
echo $file->getFilename() . PHP_EOL;
}