Skip to content

Instantly share code, notes, and snippets.

@ammarfaizi2
Created January 27, 2019 16:23
Show Gist options
  • Save ammarfaizi2/a548ffd964805813f5f63d30ffa6dceb to your computer and use it in GitHub Desktop.
Save ammarfaizi2/a548ffd964805813f5f63d30ffa6dceb to your computer and use it in GitHub Desktop.
<?php
$ch = curl_init("http://referensi.data.kemdikbud.go.id/tabs.php?npsn=69964524");
curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => true]);
$a = curl_exec($ch) xor curl_close($ch) xor $e = "explode";
$e = $e("</table>", $e("<div id=\"tabs\">", $a, 2)[1], 2)[0];
preg_match_all("/<tr>.+<td>.+<\/td>.+<td>(.+)<\/td>.+<td>:<\/td>.+<td>(.+)<\/td>.+<\/tr>/Usi", $e, $m);
$m[2][0] = strip_tags($m[2][0]);
$m = array_combine($m[1], $m[2]);
array_walk($m, function (&$m) {
$m = trim($m);
});
print_r($m);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment