Multiple Switches... with the same criteria
Posted: Sat Apr 10, 2010 6:01 am
I have recently been trying to write a section of code that will allow a video to be shown either at it's default size, or at a user value. To do this I have been using two switch statements like this:
What I want to know is - is there any way to always give these statement the same criteria? I tried this:
But it throws the error "unexpected T_INCLUDE". Is there any way to do this - maybe using variable variables?
Thanks a lot
Code: Select all
switch ($vidinfo[2])
{
case "small":
$vidwidth = 400;
break;
case "medium":
$vidwidth = 600;
break;
case "large":
$vidwidth = 800;
break;
default:
break;
}
switch ($size)
{
case "small":
$vidwidth = 400;
break;
case "medium":
$vidwidth = 600;
break;
case "large":
$vidwidth = 800;
break;
default:
break;
}
Code: Select all
switch ($vidinfo[2])
{
include($_SERVER['DOCUMENT_ROOT'] . "/videos/switch.txt");
}
switch ($size)
{
include($_SERVER['DOCUMENT_ROOT'] . "/videos/switch.txt");
}Thanks a lot