DirectoryIterator::next
(PHP 5, PHP 7, PHP 8)
DirectoryIterator::next — Move forward to next DirectoryIterator item
參數
此函式沒有參數。
返回值
沒有返回值。
範例
示例 #1 DirectoryIterator::next() example
List the contents of a directory using a while loop.
<?php
$iterator = new DirectoryIterator(dirname(__FILE__));
while($iterator->valid()) {
echo $iterator->getFilename() . "\n";
$iterator->next();
}
?>
以上例程的輸出類似於:
. .. apple.jpg banana.jpg index.php pear.jpg
參見
- DirectoryIterator::current() - Return the current DirectoryIterator item
- DirectoryIterator::key() - Return the key for the current DirectoryIterator item
- DirectoryIterator::rewind() - Rewind the DirectoryIterator back to the start
- DirectoryIterator::valid() - Check whether current DirectoryIterator position is a valid file
- Iterator::next() - 向前移動到下一個元素