|
Posted by juglesh on 10/31/05 04:57
Chung Leong wrote:
> I usually use glob() 'cause I'm lazy.
>
> http://fi.php.net/glob/
nice, i never saw that. I assume you could go *.*, can you give it
multiple matches, like *.jpg, *.gif ?
here is a func which can give an array of either folders or files:
$aListOfFiles = GetDirList($someDirectory, 'files');
$aListOfFfolders = GetDirList($someDirectory, 'folders');
function GetDirList($parent, $filesorfolders){
$oldDir = getcwd();
$list = array();
if ($handle = opendir($parent)) {
chdir($parent);
while (false !== ($file = readdir($handle))) {
if ($filesorfolders == "folders"){
if ( (is_dir($file)) && ($file != ".") && ($file !=
".."))
{$list[] = $file;
}}
if ($filesorfolders == "files"){
if ( (is_file($file)) && ($file != ".") && ($file !=
".."))
{$list[] = $file;
}}
}// while reading
closedir($handle);
chdir($oldDir);
}//if handle
sort($list);
reset($list);
return $list;
} //func
Navigation:
[Reply to this message]
|