The title pretty much says it all, but I’ve searched and tried many scripts but to no avail
I know that what I’m trying is trivial but I just can’t do it!
I have a folder, called “updates” and within it some files and other folders.
Some of these folders are prefixed with “date_” and these folders I’m interested in so I want to make a list out of them.
ex:
<ul>
<li><a href="?d=date_2008_10_05">date_2008_10_05</a></li>
....and so on
</ul>
function listFolders()
{
// get the base directory
$base_dir = dir(BASE_UPLOAD_DIR) or die("Failed opening the directory for reading");
$base_dir = '"'.BASE_UPLOAD_DIR.'"';
if (is_dir($base_dir))
{
while (($dir = readdir($base_dir)) !== FALSE)
{
if (is_dir($dir) /* && check if the folder contains "date_" */)
{
$dirs[] = array (
'name' => // get the folder name
);
}
}
closedir($base_dir);
}
return $dirs;
}
function listFolders()
{
// get the base directory
$base_dir = dir(BASE_UPLOAD_DIR) or die("Failed opening the directory for reading");
$base_dir = '"'.BASE_UPLOAD_DIR.'"';
return glob($base_dir.'date_*', GLOB_ONLYDIR);
}
$dirs = listFolders();
echo '<ul>';
foreach($dirs as $dir)
{
echo '<li><a href="?d='.$dir.'">'.$dir.'</a></li>';
}
echo '</ul>';
it doesn’t return anything… what am I missing here?