-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex2.php
111 lines (79 loc) · 2.52 KB
/
index2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="assets/bootstrap.min.css" rel="stylesheet">
<title>Boogy Test</title>
</head>
<?php
date_default_timezone_set('UTC');
function getCalendar($day, $month) {
$calendar = array();
// Set
$blank_days = date('w',mktime(0,0,0,$month,1,2013));
$days_in_month = cal_days_in_month(CAL_GREGORIAN, $month, 2013);
// Set blank days:
$i = 0;
for ($j = 2; $j < $blank_days; $j++){
$calendar['date'][$i] = 'blank';
$i++;
}
// Set valid days
$valid_day = 0;
for ($k = 0; $k < $days_in_month; $k++){
$calendar['date'][$i] = $valid_day++;
$i++;
}
//set trailing blank days
$total_days =
// Divide accumulated days into weeks:
$calendar = array_chunk($calendar['date'], 7);
foreach ($calendar as $key => $week){
if (in_array($day, $week)){
$calendar[$key - 1]['highlight'] = "highlight";
}
}
return $calendar;
}
$calendar = getCalendar(date('d'), date('m'));
//echo date('l');
// var_dump($calendar);die;
$headers = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday');
?>
<body>
<style>
tr.highlight{
background-color: red;
}
</style>
<div class="container">
<table class="table table-striped">
<thead>
<tr>
<?php foreach ($headers as $header ) { ?>
<th><?php echo $header; ?></th>
<?php } ?>
</tr>
</thead>
<tbody>
<?php
//$weeks = array_chunk($input, $size)
//var_dump($calendar);die;
foreach($calendar as $week) { ?>
<tr class='<?php if (isset($week['highlight'])){ echo 'highlight'; } ?>'>
<?php foreach($week as $day){
?>
<?php if ($day == "blank" ){
echo "<td> </td>";
} else if ($day != 'highlight'){
echo "<td>" . $day . "</td>";
}
?>
<?php } ?>
</tr>
<?php } ?>
</tbody>
</table
</div>
</body>