All right, I'm stumped. I'm trying to compare $SCRIPT_NAME to a string variable that's a member of an array; the two variables look alike when outputted, but apparently there's some subtle difference, even when I store the value of $SCRIPT_NAME in another variable and typecast it to a string to make sure.
I'm sure it's some simple dumb-newbie mistake, but can anyone explain what's happening and help me out?
What it's supposed to do:
I want each page in this section of my Website to display a list of links to every other page in the same section, but not a link to itself.
To do this, I'm using two arrays: one of the actual HTML code for each link, and one containing the file names for all pages in the section.
To display the links, the function printthelinks() is supposed to walk through the array of file names, running each one through the function checklink() to see if the current array member is the same as the $SCRIPT_NAME. If it isn't, it should print out the corresponding member variable in $Printlinks. If it's the same, it should print nothing.
Here's the URL to the page:
http://www.liberalmafia.org/about.php4
Here's the script, which you can see still contains a lot of debugging code:
//A PHP script
//Derived from that "show the URL and make the different sections into links"
//JavaScript. But here, its job is to compare the last part of the URL
//against the list of links.
//var href = document.location.href;
echo "SCRIPT_NAME variable = $SCRIPT_NAME<br>";
$Printlinks = array (
"<br><a href='feedback.php4' class='smallsidelink'>Feedback</a>",
"<br><a href='self.php4' class='smallsidelink'>About me</a>",
"<br><a href='about.php4' class='smallsidelink'>About Liberal Mafia.Org</a>",
"<br><a href='index.php4' class='smallsidelink'>Liberal Mafia index page</a>"
);
$Linkurls = array (
"/feedback.php4",
"/self.php4",
"/about.php4",
"/index.php4"
);
$length = sizeof($Printlinks);
echo "length = $length<p>";
function checklink($j,$linkmember){
$href = (string) $SCRIPT_NAME;
echo "<font size=-2>linkmember = $linkmember</font><br>";
echo "<font size=-2>script_name variable = $href</font><br>";
if ($linkmember != $href){
echo "<font size=-2>$linkmember</font><p>";
}
else {
echo "<font size=-2>linkmember name = the SCRIPT_NAME variable.</font><p>";
}
}
function printthelinks($locallength, $linkarray){
for ($i = 0; $i < $locallength; $i++)
{
checklink($i, $linkarray[$i]);
}
}
printthelinks($length, $Linkurls);