example, I had:
Code: Select all
$site_value = $_SESSION['site'];
if ($site_value=="csi")
{
$_SESSION['styled_site'] ="Administrator";
}
else if ($site_value=="beta")
{
$_SESSION['styled_site'] = "The BETA";
}
else if ($site_value=="hpcsd")
{
$_SESSION['styled_site'] = "Hyde Park";
}and I did some research on a switch from php.net and here and found:
so now I changed my code to:In many occasions, you may want to compare the same variable (or expression) with many different values, and execute a different piece of code depending on which value it equals to. This is exactly what the switch statement is for.
Code: Select all
switch ($_SESSION['site']) {
case "csi":
$_SESSION['styled_site'] ="Administrator";
break;
case "hpcsd":
$_SESSION['styled_site'] = "Hyde Park";
break;
}thanks <3
(and sorry if this is in the wrong forum)