Reputation: 27087
$today=date("d"); # today
$startdate="14"; # start of advent 14th/13th
$enddate="25"; # end of advent 24th/25th
//strtomtime
?>
<!DOCTYPE HTML><html><head><meta charset="utf-8"><title>Christmas Advant Calendar</title></head><body>
<div class="adventframework">
<?php
/*$i=$startdate;
while($i<=$enddate)
{
echo "<div class='datebox " . $i . "' id='" . $i ."'>";
echo "Today is the " . $i . "";
echo "</div>";
$i++;
}*/
if ($startdate==$today){
echo 'today and start date match';
}
The problem is that today is 01
and yet the script echos: today and start date match
when $startdate
is 14 - I am supposed to use strtotime I here; where does it go?
Upvotes: 0
Views: 141
Reputation: 1780
The problem is typecasting.
Try doing
if ((int)$startdate == (int)$today)
More over set $startdate like:
$startdate = 14; //instead of $startdate = "14"
Upvotes: 4
Reputation: 146310
Try using strcmp()
if(strcmp($startdate, $today) === 0) { //strings match
echo 'today and start date match';
}
Demo: http://codepad.org/lN90FUSa
Upvotes: 1