Hello,
I am trying to create a small php script that will display all but a few directories on my server as links. I have created the following code. I had it working when trying to ignore one directory, but now i would like to place the ignored directories within an array and ignore them that way. I am receiving the following error:
Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in /WWW/it461.dvterry.com/index.php on line 31
Code:
<?php
function listdirs($dir)
{
static $alldirs = array();
$dirs = glob($dir . '/*', GLOB_ONLYDIR);
if (count($dirs) > 0)
{
foreach ($dirs as $d) $alldirs[] = $d;
}
foreach ($dirs as $dir) listdirs($dir);
return $alldirs;
}
$ignoreArray = array("./test","./Homework_2");
?>
<html>
<head>
<title>
Main
</title>
</head>
<body>
<?php
foreach(listdirs('.') as $dir)
{
if (!in_array($dir, $ignoreArray))
// if ( $dir != "./Homework_2");
{
echo "<a href="$dir">"$dir"</a><br />";
}
}
?>
</body>
</html>
Thanks!!