$currentpage = basename($_SERVER['PHP_SELF']); // e.g. index.php
$pagesection = substr($currentpage, 3, 4); // e.g. 3001, 3002, 3003... goes to 3089)
$orderofarray = $pagesection-3000; // e.g. 1, 2, 3... 89
// ARRAY KEY ARRAY VALUES
// PHP FILES IN SITE LINKS IN DYNAMIC MENU
$links1 = array("01-3001-01.php" => "Section 1 Page 1",
"01-3001-02.php" => "Section 1 Page 2",
"01-3001-03.php" => "Section 1 Page 3",
"01-3001-04.php" => "Section 1 Page 4",
"01-3001-05.php" => "Section 1 Page 5",
);
$links2 = array("01-3002-01.php" => "Section 2 Page 1",
"01-3002-02.php" => "Section 2 Page 2",
"01-3002-03.php" => "Section 2 Page 3",
"01-3002-04.php" => "Section 2 Page 4",
"01-3002-05.php" => "Section 2 Page 5",
);
$links3 = array("01-3003-01.php" => "Section 3 Page 1",
"01-3003-02.php" => "Section 3 Page 2",
"01-3003-03.php" => "Section 3 Page 3",
"01-3003-04.php" => "Section 3 Page 4",
"01-3003-05.php" => "Section 3 Page 5",
);
$picklinks = array("",
$links1,
$links2,
$links3,
);
foreach($picklinks[$orderofarray] as $filename=>$filetitle)
{
//Uses $currentpage to figure out which links to display in the menu, BUT it also
//Goes through each value in selected array and prints it accordingly (where I need help):
if($currentpage=="index.php")
{
}
//If the current page is index.php, then nothing happens.
elseif($currentpage==$filename)
{
//If the current page is listed in the array key, then...
$reuseable = substr($filetitle, 10);
}
//...this is the variable I want to use in header.inc and body.inc
elseif($currentpage!=$filename)
{
}
//If the current page does not match up with an array key, then nothing happens.
}
MY GOAL
1. Use the variable $reuseable in the html title tags of the header.inc file.
2. Use the variable $reuseable in the body of my pages.
3. Use the variable $reuseable anywhere without having to copy and paste the array code above into each include file.
IDEAS THAT GOT ME NOWHERE
1. Globals
2. Sessions
3. Cookies
HELP IF YOU CAN... 😕