Alright, I have a function that will take the file name and print the title and a "map" to that page. My code is below.
function display_map($type, $filename){
if ($filename == ""){
$fullPath = $_SERVER['REQUEST_URI'];
$tmpArray = split("/", $fullPath);
$count = count($tmpArray);
$filename = $tmpArray[$count - 1];
}
$file = array();
$title = array();
$map = array();
$file[0] = "index.php";
$title[0] = "Home";
$map[0] = "a";
$file[1] = "news.php";
$title[1] = "News";
$map[1] = "<a href=\"index.php\">Home</a> > News";
$file[2] = "games.php";
$title[2] = "Games";
$map[2] = "<a href=\"index.php\">Home</a> > Games";
$file[3] = "games.php?category=1";
$title[3] = "Action Games";
$map[3] = "<a href=\"index.php\">Home</a> > Action Games";
$k = count($file);
for ($i=0; $i<$k; $i++){
if ($filename == $file[$i])
if ($type == "map"){
return $map[$i];
} else if ($type == "title") {
return $title[$i];
}
}
display_map($type, basename($_SERVER['PHP_SELF']));
}
It would work fine, however, I have pages that are like games.php?category=1, etc. I have a bunch more pages listed in my script, but I removed them so the script is shorter
Now, the problem is that if for some reason, someone types in the page index.php?, nothing will be displayed because of the ? at the end. I thought that I would be able to call the function again at the end if nothing was returned, and I use the basename() function to strip all the garbage off the filename but for some reason, nothing is returned. I tested it a bunch of times, and everything works fine, but nothing is returned for some reason. Anyone know why? Its late and its probably a small thing, but this is driving me crazy...
Also, am I making this whole thing more complicated than it has to be? Its been a while since I coded...
Thanks in advance.