I have a script that lists directory contents and produces a drop-down menu with options, and it works.
The problem is - now I need two of such scripts within the same page, where each would list a different directory and generate it's own menu.
Error message:
Fatal error: Cannot redeclare getdirfiles()
(previously declared in C:\Apache\Apache2\htdocs\abraWeb\fr\galeries.php:17)
in C:\Apache\Apache2\htdocs\abraWeb\fr\galeries\forms.php on line 65
The page they are in includes three diferent scripts as the following code into 3 cells of a table.
Goes something like this (just a part I have a problem with):
function getDirFiles($dirPath)
{
if ($handle = opendir($dirPath)) {
while (($file = readdir($handle)) !== false)
if ($file != "." && $file != ".." && !is_dir($dirPath.$file)) {
$filesArr[] = $file;
}
closedir($handle);
}
return $filesArr;
}
$directory = 'hr/portfolio/press/';
$remdirectory = 'hr/portfolio/press/';
$separator = "/";
$filelist = getDirFiles($directory);
natcasesort($filelist);
?>
If it's only one on the page, the latter works. The problem appears if I try using more than one.
What do I do to make 2-3 menus within the same page work?
Don't know if it's important, the pages chosen with options are later included using:
if (isset($_GET['nav'])) {
include($_GET['nav']);
}
Thanks a lot,
😉