04-09-2009, 01:38 PM
|
#13 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
Maybe I'm just misreading this thread but I think Peuplarchie is asking for the folders to be displayed first (in bold) and then the files afterwards.
Using the yummy SPL approach we can just iterate over the directory contents twice:
PHP Code:
$path = './path/to/dir';
$files = new DirectoryIterator($path);
// 1. List only folders
foreach ($files as $file)
{
if ($file->isDir() && ! $file->isDot())
echo '<strong>', $file, '</strong>', "\n";
}
// 2. List only files
foreach ($files as $file)
{
if ($file->isFile())
echo $file, "\n";
}
|
|
|
|