-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
38 lines (34 loc) · 746 Bytes
/
index.php
File metadata and controls
38 lines (34 loc) · 746 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
<?php
require "movies.php";
echo "inter your age: ";
$age=readline("inter your age: ");
switch ($age)
{
case ($age===0):
findMovies($movies,$age);
break;
case($age>0 && $age<12):
findMovies($movies,$age);
break;
case($age>0 && $age<=14):
findMovies($movies,$age);
break;
case($age>0 && $age<=16):
findMovies($movies,$age);
break;
case($age>0 && $age>=18):
findMovies($movies,$age);
break;
default:
echo "Enter currect age!";
}
function findMovies(array $movies,int $age): void
{
$i=1;
foreach ($movies as $movie){
if ($movie['age_restriction']<=$age){
echo "{$i} . {$movie['title']} ({$movie['release_year']}), {$movie['age_restriction']}+. Rating- {$movie['rating']}" ."\n";
$i++;
}
}
}