Check if current DirectoryIterator item is a regular file in PHP
Description
The following code shows how to check if current DirectoryIterator item is a regular file.
Example
/* w w w .j ava 2s . c om*/
//This example will list all regular files in the directory containing the script.
<?php
$iterator = new DirectoryIterator(dirname(__FILE__));
foreach ($iterator as $fileinfo) {
if ($fileinfo->isFile()) {
echo $fileinfo->getFilename() . "\n";
}
}
?>
The code above generates the following result.