Check if current DirectoryIterator item is '.' or '..' in PHP
Description
The following code shows how to check if current DirectoryIterator item is '.' or '..'.
Example
//from w w w .ja va 2s . co m
//This example will list all files, omitting the . and .. entries.
<?php
$iterator = new DirectoryIterator(dirname(__FILE__));
foreach ($iterator as $fileinfo) {
if (!$fileinfo->isDot()) {
echo $fileinfo->getFilename() . "\n";
}
}
?>
The code above generates the following result.