I'm trying to learn PHP and challenged myself with this simple demo to learn how to use arrays. The challenge: display a string that will show a restaurant's daily special for the appropriate day.
Sunday = closed
Monday = Taco
Tuesday = Chicken
Wednesday = Lasagna
Thursday = Sushi
Friday = Salmon
Saturday = Steak
Example if the current day is Thursday:
Today's special is Sushi.
Here's the baseline I've been working from:
<?php
date_default_timezone_set('America/New_York');
$day = date('l');
$days = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
$specials = array('closed','Taco','Chicken','Lasagna','Sushi','Salmon','Steak');
?>
<p>Today is <?php echo $day; ?></p>
<p>Today's Special is: <?php Cant Figure Out What Goes Here ?></p>
foreach($arrayname as $key => $special) { if($day == $key)} echo $special {;date('w')and use that as the array index ($days[date('w')]).