loop in switch
Posted: Wed Feb 02, 2011 6:43 am
Okay so I am trying to make variable case names.
So I have this:
the error I get is:
Parse error: syntax error, unexpected T_FOR, expecting T_CASE or T_DEFAULT or '}' in ------------------------\template.php on line 99
So I am assuming this means I cant have a for statement in a switch so is there any other way around this? I've been trying too many things but having no luck
Cheers,
Dom
So I have this:
Code: Select all
$handle = opendir(TPATH_BASE.DS.'content');
for($i=0; false !== ($file = readdir($handle)); $i++){
if ($file !== '' && $file !== 'default.php'){
$case[$i] = $file;
}
}
$count = count($case);
switch ($frame){
for($x=0; $x<=$count; $x++){
$cas[$x] = strstr($case[$x], '.', TRUE);
case $cas[$x]:
include_once (TPATH_BASE.DS.'content'.$case[$x]);
break;
}
default:
include_once (TPATH_BASE.DS.'content'.$case[x].'default');
}
Parse error: syntax error, unexpected T_FOR, expecting T_CASE or T_DEFAULT or '}' in ------------------------\template.php on line 99
So I am assuming this means I cant have a for statement in a switch so is there any other way around this? I've been trying too many things but having no luck
Cheers,
Dom