Create a new directory iterator from a path and list contents of the directory containing the script in PHP
Description
The following code shows how to create a new directory iterator from a path and list contents of the directory containing the script.
Example
<?php// w w w. j av a 2 s . c om
$dir = new DirectoryIterator(dirname(__FILE__));
foreach ($dir as $fileinfo) {
if (!$fileinfo->isDot()) {
var_dump($fileinfo->getFilename());
}
}
?>
The code above generates the following result.