Get the key for the current DirectoryIterator item in PHP
Description
The following code shows how to get the key for the current DirectoryIterator item.
Example
/*from w ww .j av a 2s . c o m*/
<?php
$dir = new DirectoryIterator(dirname(__FILE__));
foreach ($dir as $fileinfo) {
if (!$fileinfo->isDot()) {
echo $fileinfo->key() . " => " . $fileinfo->getFilename() . "\n";
}
}
?>
The code above generates the following result.