I want to determine if $today
is a known non-working day or holiday by comparing two arrays and report the result. I do not know what belongs in the if
and elseif
structures to compare if the variable within the array is a match to $today
:
<?php
// Date & Time
$timeadjust = '-5 hours';
$today_long = date('l, d F Y', strtotime($timeadjust));
$today = date('m-d', strtotime($timeadjust));
$today_day_name = date('l', strtotime($timeadjust));
// Normal Non-Working Days
$saturday = 'Saturday';
$sunday = 'Sunday';
// 2015 Holidays
$new_years_day = '01-01';
$fourth_of_july = '07-04';
$thanksgiving = '11-26';
$thanksgiving_friday = '11-27';
$christmas_eve = '12-24';
$christmas = '12-25';
$new_years_eve = '12-31';
// Normal Non-Working Day Array
$no_work = array($saturday,$sunday);
// Holiday Array
$holiday = array($new_years_day,$fourth_of_july,$thanksgiving,$thanksgiving_friday,$christmas_eve,$christmas,$new_years_eve);
// Compare Today To Normal Non-Working Day & Holiday Arrays To Determine If Today Is Normal Non-Working Day Or Holiday
if ($today_day_name = $no_work) {$operating = 'CLOSED';}
elseif ($today = $holiday) {$operating = 'CLOSED';}
else {$operating = 'OPEN';}
// Display Result Of Comparison & Report Operating Status
echo '<h3>Today is '.$today_long.'. We are '.$operating.' today!</h3>';
?>