Forum Moderators: coopster
What I would like to do is automate the $pass array. that list is actually a list of file names in a directory but with the file ext removed.
So far I can't find any information on what I would like to achieve on the board.
$pass = array('home','contact','error','etc');
$page="";
if (in_array($_GET['id'], $pass))
{
$page=$_GET['id'].".php";
}
elseif (!isset($_GET['id']))
{
$page="home.php";
}
else
{
$page="error.php";
}
Use the dir class [php.net] that is built into PHP. There is a good example on the page that shows how to do it.
If you need additional help, just reply and I can help you with the details.
Example:
If you want to list all the .txt files you could do something like
foreach (glob('*.txt') as $filename) {
$pass[]=str_replace('.txt','',$filename);
}