function listFiles($dir, $type = "all") { $x = 0; if(is_dir($dir)) { $thisdir = dir($dir); $result = ''; while($entry=$thisdir->read()) { if(($entry!='.')&&($entry!='..')) { if ($type == "all") { $result[$x] = $entry; $x++; next($result); } $isFile = is_file("$dir$entry"); $isDir = is_dir("$dir$entry"); if (($type == "files") && ($isFile)) { $result[$x] = $entry; $x++; next; } if (($type == "dir") && ($isDir)) { $result[$x] = $entry; $x++; next; } $temp = explode(".", $entry); if (($type == "noext") && (strlen($temp[count($temp) - 1]) == 0)) { $result[$x] = $entry; $x++; } if (($isFile) && (strtolower($type) == strtolower($temp[count($temp) - 1]))) { $result[$x] = $entry; $x++; } } } return $result; } } ?>
|