Advertisement
Guest User

Untitled

a guest
Apr 8th, 2020
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.14 KB | None | 0 0
  1. <?php
  2.    
  3.     function getCurl($url) {
  4.         $ch = curl_init();
  5.         curl_setopt($ch, CURLOPT_URL, $url);
  6.         curl_setopt($ch, CURLOPT_RETURNTRANSFER,0);
  7.         $result = curl_exec($ch);
  8.         curl_close($ch);
  9.         return json_decode($result, true);
  10.     }
  11.  
  12.  $kode_wilayah1 = "190200";  // Kab.Pangkep
  13.     // alamat API
  14.     $url_daftar_sekolah = "http://jendela.data.kemdikbud.go.id/api/index.php/Csekolah/rekapSekolahGET?mst_kode_wilayah=".$kode_wilayah1;
  15.    
  16. $result =getCurl($url_daftar_sekolah);
  17.  
  18. ?>
  19.  
  20. <!DOCTYPE html>
  21. <html lang="en">
  22. <head>
  23.     <meta charset="UTF-8">
  24.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  25.     <title>Daftar Sekolah</title>
  26. </head>
  27. <body>
  28.     <table>
  29.         <tr>
  30.             <th>Kecamatan</th>
  31.             <th>Kategori</th>
  32.             <th>Jumlah</th>
  33.         </tr>
  34.         <?php foreach($result as $row) : ?>
  35.         <tr>
  36.             <td><?= $row['data']['wilayah']; ?></td>
  37.             <td><?= $row['data']['bentuk']; ?></td>
  38.             <td><?= $row['data']['sekolah']; ?></td>
  39.         </tr>
  40.         <?php endforeach; ?>
  41.     </table>
  42. </body>
  43. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement