This function, as far as I can tell, returns boolean, not string.
$di = new DirectoryIterator(/path/to/iterate);
while ($di->valid())
{
echo $di->getPathname() . "\n";
$di->next();
}
DirectoryIterator::valid
(PHP 5)
DirectoryIterator::valid — Check whether current DirectoryIterator position is a valid file
Beschreibung
public bool DirectoryIterator::valid
( void
)
Check whether current DirectoryIterator position is a valid file.
Parameter-Liste
Diese Funktion hat keine Parameter.
Rückgabewerte
Returns TRUE if the position is valid, otherwise FALSE
Beispiele
Beispiel #1 A DirectoryIterator::valid() example
<?php
$iterator = new DirectoryIterator(dirname(__FILE__));
// Loop to end of iterator
while($iterator->valid()) {
$iterator->next();
}
$iterator->valid(); // FALSE
$iterator->rewind();
$iterator->valid(); // TRUE
?>
Siehe auch
- DirectoryIterator::current() - Return the current DirectoryIterator item.
- DirectoryIterator::key() - Return the key for the current DirectoryIterator item
- DirectoryIterator::next() - Move forward to next DirectoryIterator item
- DirectoryIterator::rewind() - Rewind the DirectoryIterator back to the start
- Iterator::valid() - Prüft, ob die aktuelle Position zulässig ist
josh dot butts at vertive dot com
02-Sep-2008 03:47
