I have this array
$array = array(
date => '2015-07-08',
title => 'Sample'
);
And this is my script for calendar
$calendar = mktime(0,0,0,date("n"),1,date("Y"));
$getprevdays = mktime(0,0,0,date("n")-1,1,date("Y"));
$thisday = getdate($calendar);
$startday = $thisday['wday'];
$maxday = date("t", $calendar);
$year = date("Y", $calendar);
$month = date("n", $calendar);
echo "<table border='1'>";
echo "<tr>";
echo "<th>Sunday</th>";
echo "<th>Monday</th>";
echo "<th>Tuesday</th>";
echo "<th>Wednesday</th>";
echo "<th>Thursday</th>";
echo "<th>Friday</th>";
echo "<th>Saturday</th>";
echo "</tr>";
for($i=0;$i<($maxday+$startday);$i++){
if(($i%7)==0) echo "<tr>";
if($i<$startday) echo "<td></td>";
else{
echo "<td>" . ($i - $startday + 1);
foreach($array $as $arr){
if(date('d', strtotime($arr['date']) == ($i - $startday + 1)){
echo $arr['title']
}
}
echo "</td>"; //This is where to display data
}
if(($i%6)==1) "</tr>";
}
echo "</table>";
Im trying to display the title based on the date given.
In my script, It display the calendar of the current month and produced table like data. In each cell, displays the current day of the month and it can also contain data. I tried using this codes,
foreach($array $as $arr){
if(date('d', strtotime($arr['date']) == ($i - $startday + 1)){
echo $arr['title']
}
}
($i - $startday + 1) this codes display the number of day of the month, so if the day of the date is the same, that is when it will echo the title. Any idea on how can I achieve this?