-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2301.php
More file actions
47 lines (44 loc) · 962 Bytes
/
2301.php
File metadata and controls
47 lines (44 loc) · 962 Bytes
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
<?php
function quarterOf($month): int
{
if ($month >= 1 && $month <= 12) {
if ($month < 4) {
return 1;
} elseif ($month >= 4 && $month < 7) {
return 2;
} elseif ($month >= 7 && $month < 10) {
return 3;
} else {
return 4;
}
} else {
return 0;
}
}
echo quarterOf(11);
function quaterOf2($month): int
{
switch (true) {
case $month >= 1 && $month <= 3:
return 1;
case $month >= 4 && $month <= 6:
return 2;
case $month >= 7 && $month <= 9:
return 3;
case $month >= 10 && $month <= 12:
return 4;
default:
return 0;
}
}
echo quaterOf2(3);
function even_or_odd(int $n): string
{
return ($n % 2 == 0) ? 'Even' : 'Odd';
}
echo even_or_odd(12);
function sum(array $a): float
{
return (count($a) > 0) ? array_sum($a) : 0;
}
echo sum([1, -2.2, 3]);