Hello,
I have a huge switch statement, the beginning follows here:
switch ($section_name) {
case "home":
$file_name = "./website/side/side_" . $section_name . ".htm";
$side = get_side($file_name);
break;
case "about":
$num = count ($about_section_array);
for ($i=0; $i < $num; $i++) {
if ($about_section_array[$i] == $page_name) {
$side = $side . " <b><a href='http://www.stgeorge.org/" . $script_name . "?section=" . $section_name . "&page=" . $about_section_array[$i] . "'>" . $about_section_name_array[$i] ."</a></b><br>";
} else {
$side = $side . " <a href='http://www.stgeorge.org/" . $script_name . "?section=" . $section_name . "&page=" . $about_section_array[$i] . "'>" . $about_section_name_array[$i] ."</a><br>";
}
}
break;
case "cal":
... six or seven times ...
I would like to know if there is a way to shorten this, since it's now a huge piece of code. All each case statement does is take values from an array (the array name is the only one that changes based on the switch statement) and sends them to the browser.
And ideas to get rid of this ugly code?
Thank you!
Dinos P.