I am experimenting with the date and in_array functions of PHP.
Based on what I have read in the manual I can't understand why my code is returning the else part of the if statement. If the date('D') is returning Tue why doesn't it run the if part?
<?php
date_default_timezone_set('UTC');
$weekdays = array("Mon", "Tue", "Wed", "Thur", "Fri", "Sat", "Sun");
$today = date('D');
if(in_array("Mon", "Tue", "Wed", "Thur", "Fri", $weekdays) == $today)
{
echo "It's" . " ";
echo $today;
echo " " . "Get out of bed and go to work";
}else{
echo "Do whatever you want becuase it's" . " ";
echo $today;
};
?>
I've tried various things and and changed the if part to this, but to no avail.
if(in_array(array("Mon", "Tue", "Wed", "Thur", "Fri"), $weekdays) == $today)
Can someone tell me what is wrong with the syntax?