Jump to content

Create array of subdirectories, no files, nonrecursive..


cgm225

Recommended Posts

I would use the read_dir() function:

 

<?php
$dirs = array();
if ($handle = opendir('/path/to/directory')) {
    while (false !== ($file = readdir($handle))) {
        if (is_dir('/path/to/directory/' . $file) && $file != '.' && $file != '..')
             $dirs[] = $file;
    }
    closedir($handle);
}
echo '<pre>' . print_r($dirs,true) .'</pre>'; // just checking
?>

 

Ken

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.