View Single Post
Old 04-09-2009, 01:38 PM   #13 (permalink)
Salathe
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

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";

Salathe is offline  
Reply With Quote