-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsuperheroes.php
109 lines (93 loc) · 3.49 KB
/
superheroes.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
<?php
$superheroes = [
[
"id" => 1,
"name" => "Steve Rogers",
"alias" => "Captain America",
"biography" => "Recipient of the Super-Soldier serum, World War II hero Steve Rogers fights for American ideals as one of the world’s mightiest heroes and the leader of the Avengers.",
],
[
"id" => 2,
"name" => "Tony Stark",
"alias" => "Ironman",
"biography" => "Genius. Billionaire. Playboy. Philanthropist. Tony Stark's confidence is only matched by his high-flying abilities as the hero called Iron Man.",
],
[
"id" => 3,
"name" => "Peter Parker",
"alias" => "Spiderman",
"biography" => "Bitten by a radioactive spider, Peter Parker’s arachnid abilities give him amazing powers he uses to help others, while his personal life continues to offer plenty of obstacles.",
],
[
"id" => 4,
"name" => "Carol Danvers",
"alias" => "Captain Marvel",
"biography" => "Carol Danvers becomes one of the universe's most powerful heroes when Earth is caught in the middle of a galactic war between two alien races.",
],
[
"id" => 5,
"name" => "Natasha Romanov",
"alias" => "Black Widow",
"biography" => "Despite super spy Natasha Romanoff’s checkered past, she’s become one of S.H.I.E.L.D.’s most deadly assassins and a frequent member of the Avengers.",
],
[
"id" => 6,
"name" => "Bruce Banner",
"alias" => "Hulk",
"biography" => "Dr. Bruce Banner lives a life caught between the soft-spoken scientist he’s always been and the uncontrollable green monster powered by his rage.",
],
[
"id" => 7,
"name" => "Clint Barton",
"alias" => "Hawkeye",
"biography" => "A master marksman and longtime friend of Black Widow, Clint Barton serves as the Avengers’ amazing archer.",
],
[
"id" => 8,
"name" => "T'challa",
"alias" => "Black Panther",
"biography" => "T’Challa is the king of the secretive and highly advanced African nation of Wakanda - as well as the powerful warrior known as the Black Panther.",
],
[
"id" => 9,
"name" => "Thor Odinson",
"alias" => "Thor",
"biography" => "The son of Odin uses his mighty abilities as the God of Thunder to protect his home Asgard and planet Earth alike.",
],
[
"id" => 10,
"name" => "Wanda Maximoff",
"alias" => "Scarlett Witch",
"biography" => "Notably powerful, Wanda Maximoff has fought both against and with the Avengers, attempting to hone her abilities and do what she believes is right to help the world.",
],
];
?>
<?php
if($_SERVER['REQUEST_METHOD'] === 'GET'){
$name = $_GET["query"];
$name = strip_tags($name);
$name = strtolower($name);
$found = false;
$list = '';
echo "<h1>RESULT</h1><hr></hr>";
if($name == ""){
echo "<ul>";
foreach ($superheroes as $superhero):
echo "<li>".strtoupper($superhero['alias'])."</li>";
endforeach;
echo "</ul>";
return;
}
foreach ($superheroes as $superhero):
if($name == strtolower($superhero['name']) or $name == strtolower($superhero['alias'])){
echo "<h3>".strtoupper($superhero['alias'])."</h3>";
echo "<h4> A.K.A ".strtoupper($superhero['name'])."</h4>";
echo "<p>".$superhero['biography']."</p>";
$found = true;
}
endforeach;
if($found == false){
echo "<h3 class='red'>Superhero not found</h3>";
}
}
?>