I have a delivery service that only picks up Monday through Thursday. I only want to give the user the next available three days as an option for a scheduled pickup.
My code works, but I was wondering if there was a more "efficient" way to write what Im trying to achieve?
$numericDay=date('N');
if ($numericDay==1) {
echo '<option value="' . date('Ymd', strtotime('+1 days')) . '">' . date('\T\o\m\o\o\w - F j, Y', strtotime('+1 days')) . '</option>';
echo '<option value="' . date('Ymd', strtotime('+2 days')) . '">' . date('l - F j, Y', strtotime('+2 days')) . '</option>';
echo '<option value="' . date('Ymd', strtotime('+3 days')) . '">' . date('l - F j, Y', strtotime('+3 days')) . '</option>';
}
if ($numericDay==2) {
echo '<option value="' . date('Ymd', strtotime('+1 days')) . '">' . date('\T\o\m\o\o\w - F j, Y', strtotime('+1 days')) . '</option>';
echo '<option value="' . date('Ymd', strtotime('+2 days')) . '">' . date('l - F j, Y', strtotime('+2 days')) . '</option>';
echo '<option value="' . date('Ymd', strtotime('next monday')) . '">' . date('l - F j, Y', strtotime('next monday')) . '</option>';
}
if ($numericDay==3) {
echo '<option value="' . date('Ymd', strtotime('+1 days')) . '">' . date('\T\o\m\o\o\w - F j, Y', strtotime('+1 days')) . '</option>';
echo '<option value="' . date('Ymd', strtotime('+next monday')) . '">' . date('l - F j, Y', strtotime('next monday')) . '</option>';
echo '<option value="' . date('Ymd', strtotime('next tuesday')) . '">' . date('l - F j, Y', strtotime('next tuesday')) . '</option>';
}
if ($numericDay>=4 and $numericDay<=7) {
echo '<option value="' . date('Ymd', strtotime('next monday')) . '">' . date('l - F j, Y', strtotime('next monday')) . '</option>';
echo '<option value="' . date('Ymd', strtotime('next tuesday')) . '">' . date('l - F j, Y', strtotime('next tuesday')) . '</option>';
echo '<option value="' . date('Ymd', strtotime('next wednesday')) . '">' . date('l - F j, Y', strtotime('next wednesday')) . '</option>';
}
Thanks in advance for any insight!!!