I'm new to php & scripting in general. I was hoping someone could help me out with this. I have a switch statement that serves as a simple template system for a site:
switch($content)
{
case "page1":
$contentName="page1";
$pageTitle="title";
$headerimage="page1.jpg";
break;
case "page2":
$contentName="page2";
$pageTitle="title";
$headerimage="page2.jpg";
break;
etc. etc.
I'm sure this could easily be written in a for loop, but it's not working so far. These are examples of my unsucessful attempts:
_____(1)______
for ($page_num=1; $page_num<=14; $page_num++)
{
case "page" . $page_num:
$contentName="page" . $page_num;
$pageTitle="page title";
$headerimage="page" . $page_num . ".jpg";
break;
}
_____( end 1)___
____(2)________
for($i=0;$i<$14;$i++)
{
$fbaskets=${"page$i"};
case "page$i":
$contentName="page$i";
$pageTitle="page title";
$headerimage="page$i.jpg";
break;
}
_____(end 2)______
How do I get that whole block of code to be written by the loop inside the switch statement? Can I even have a loop inside the switch? Much thanks to anyone that can help me out with this!