Seek to a DirectoryIterator item in PHP
Description
The following code shows how to seek to a DirectoryIterator item.
Example
/* w w w . j ava 2s . com*/
//Seek to the fourth item in the directory containing the script.
//The first two are usually . and ..
<?php
$iterator = new DirectoryIterator(dirname(__FILE__));
$iterator->seek(3);
if ($iterator->valid()) {
echo $iterator->getFilename();
} else {
echo 'No file at position 3';
}
?>
The code above generates the following result.