Check if current DirectoryIterator position is a valid file in PHP
Description
The following code shows how to check if current DirectoryIterator position is a valid file.
Example
<?php// w w w. java 2s. co m
$iterator = new DirectoryIterator(dirname(__FILE__));
// Loop to end of iterator
while($iterator->valid()) {
$iterator->next();
}
$iterator->valid(); // FALSE
$iterator->rewind();
$iterator->valid(); // TRUE
?>