How do you write a code that merges these similar multiple codes into one? E.g.
<?php
$content = array(
1 => "dir/filename.php",
2 => "other.php",
3 => "andso/on.php",
);
$day = date('W');
$file = isset($content[$day]) ? $content[$day] : 'notes.php';
include $file;
?>
The main page uses an include (the code above) for the content part.
<?php
$sidebar = array(
1 => "dir/filename/sidebar.php",
2 => "other-sidebar.php",
3 => "andson/sidebar.php",
);
$day = date('W');
$file = isset($sidebar[$day]) ? $sidebar[$day] : 'notes.php';
include $file;
?>
The main page uses an include for the sidebar part.
<?php
$title = array(
1 => "title of filename",
2 => "other title",
3 => "and so on",
);
$day = date('W');
[not sure how to code this line]
echo $title;
?>
Rather than repeating the same, how do you code three together in an array?
For example, CONCEPT below:
<?php // code above header
$rotate = array(
1 => "dir/filename.php", "sidebar/file.php", "title here"
2 => "other.php", "sidebar/anotherfile.php", "title here"
3 => "andso/on.php", "sidebar/antoher.php, "title here"
$day = date('W');
$file = isset($content[$day]) ? $content[$day] : 'ls.php';
$sidebar = isset($content[$day]) ? $content[$day] : 'j.php';
$title = isset($title[$day]) ? $title[$day] : 'Title';
?>
<? // place an include in the main page
include $file;
?>
<? // place an include in the sidebar of the main page
include $sidebar; ?>
<? // place a title in the main page
echo $title; ?>
Thank you and greatly appreciated in advance.