forked from kokonior/PHP-Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcovid.php
41 lines (32 loc) · 914 Bytes
/
covid.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
<?php
function curl($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
$send = curl("https://api.kawalcorona.com/indonesia/");
// mengubah JSON menjadi array
$data = json_decode($send, TRUE);
echo "<pre>";
print_r();
echo "</pre>";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Data Covid Indonesia</title>
</head>
<body>
<p>Negara : <?= $data[0]['name']; ?></p>
<p>Positif : <?= $data[0]['positif']; ?></p>
<p>Sembuh : <?= $data[0]['sembuh']; ?></p>
<p>Meninggal : <?= $data[0]['meninggal']; ?></p>
<p>Dirawat : <?= $data[0]['dirawat']; ?></p>
</body>
</html>