I’m trying to read a directory of files while avoiding files that are not readable.
Here is the code that i have but is not working.
[CODE]
/*{{{ readdir: reads in a directory (non-recursively) optionally testing filenames against a provided regex string */
function readdir($dir,$match = null) {
$files = array();
$file = “”;
$d = dir($dir);
while (false !== ($file = $d->read())) {
if(true == is_readable($file)){
if ($file{0} == ‘.’)
continue;
else if (isset($match) && preg_match($match,$file))
$files[] = $file;
else if (!isset($match))
$files[] = $file;
}
}
$d->close();
sort($files);
return $files;
}/*}}}*/
Can anyone tell me what i’m doing wrong? To me it seems like the is_readable() is not working correctly…