DirectoryIterator::next

Move forward to next DirectoryIterator item

&reftitle.description; public `void` `DirectoryIterator::next`

Move forward to the next `DirectoryIterator` item.

&reftitle.parameters; &no.function.parameters;
&reftitle.returnvalues;

&return.void;

&reftitle.examples;

### `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();
    }
    ?>

&example.outputs.similar;

    .
    ..
    apple.jpg
    banana.jpg
    index.php
    pear.jpg

&reftitle.seealso;

- `DirectoryIterator::current`
- `DirectoryIterator::key`
- `DirectoryIterator::rewind`
- `DirectoryIterator::valid`
- `Iterator::next`