-
Notifications
You must be signed in to change notification settings - Fork 0
/
switch.php
48 lines (41 loc) · 834 Bytes
/
switch.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
<?php
// Finish the switch statement to output the day of the week corresponding with the variable, then create a matching if block for the switch statement.
date_default_timezone_set('America/Chicago');
$dayOfWeek = date('N');
switch($dayOfWeek) {
case 1:
echo "Monday\n";
break;
case 2:
echo "Tuesday\n";
break;
case 3:
echo "Wednesday\n";
break;
case 4:
echo "Thursday\n";
break;
case 5:
echo "Friday\n";
break;
case 6:
echo "Saturday\n";
break;
default:
echo "Sunday\n";
}
if ($dayOfWeek == 1) {
echo "Monday\n";
} elseif ($dayOfWeek == 2) {
echo "Tuesday\n";
} elseif ($dayOfWeek == 3) {
echo "Wednesday\n";
} elseif ($dayOfWeek == 4) {
echo "Thursday\n";
} elseif ($dayOfWeek == 5) {
echo "Friday\n";
} elseif ($dayOfWeek == 6) {
echo "Saturday\n";
} else {
echo "Sunday\n";
}