Forum Moderators: coopster
I really can't figure out why my script isn't working other than thinking that I can't have multiple OR (¦) operators in my IF statement.
I want my script to hide a list of items unless the visitor is on a certain page - indicated by the variables.
Can anyone help me figure out why it's not working?
Thanks
<?php // page variables$vb = 'index.php';
$vp = 'blah.php';
$vc = 'blah2.php';
// display the div if active page is found within it
function displaynav() {
$currentPage = end(explode('/', $_SERVER['REQUEST_URI']));
if ($currentPage!== $vb ¦ $vp ¦ $vc) {
echo ' style="display:none;"';
}
}
?>
If it's like the example below, then how would I specify multiple variables in my function?
Would it be like so?
displaynav($var1, $var2, $var3); General function:
<?phpfunction displaynav($page) {
$currentPage = end(explode('/', $_SERVER['REQUEST_URI']));
if ($currentPage!== $page) {
echo ' style="display:none;"';
}
}
?>
You need to explain your problem. Something like below would work though.
<?php $allowed=array('index.php', 'blah.php', 'blah2.php');
$currentPage =basename( $_SERVER['PHP_SELF']);
if (in_array($currentPage, $allowed))
{
// your list goes here.
}
?>