function get_filenamesbydir($dir) { $files = array(); get_allfiles($dir, $files); return $files; }
/** * @bref:获取一个文件夹下面的所有文件的数组,除了隐藏文件(.xx)和备份文件(~xx) * @param $path * @param $files * @author liuhengsheng */ function get_allfiles($path, &$files) { if (is_dir($path)) { $dp = dir($path); while ($file = $dp->read()) { if ($file != "." && $file != "..") { get_allfiles($path . "/" . $file, $files); } } $dp->close(); } if (is_file($path)) { $temp = explode('/', $path); $fileName = array_pop($temp); if (strpos($fileName, '.') !== 0 && strpos($fileName, '~') !== 0) { $files[] = $path; } } }
function get_allfiles($path, &$files) { if (is_dir($path)) { $dp = dir($path); while ($file = $dp->read()) { if ($file != "." && $file != "..") { get_allfiles($path . "/" . $file, $files); } } $dp->close(); } if (is_file($path)) { $files[] = $path; } }