In response to the comment below, you don't have to simulate a foreach(), DirectoryIterator obviously inherits SPL's Iterator interface, therefore:
<?php
$dir = new DirectoryIterator("/tmp");
foreach ($dir as $file) {
if ($dir->isDot()) {
continue;
}
echo $file . "\n";
}
?>