-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
62 lines (54 loc) · 2.08 KB
/
functions.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
<?php
function get_curl($url)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
curl_close($curl);
return json_decode($result, true);
}
function get_surah()
{
$result = get_curl("https://api.quran.sutanlab.id/surah");
$surah = [];
$i = 0;
foreach ($result["data"] as $result) {
$surah[$i]["no_surah"] = $result["number"];
$surah[$i]["nama_surah"] = $result["name"]["transliteration"]["id"];
$surah[$i]["arti_surah"] = $result["name"]["translation"]["id"];
$surah[$i]["turun_surah"] = $result["revelation"]["id"];
$surah[$i]["ayat_surah"] = $result["numberOfVerses"];
$i++;
}
return $surah;
}
function get_ayat($surah_id)
{
$result = get_curl("https://api.quran.sutanlab.id/surah/" . $surah_id . "");
$result = $result["data"];
$surah = [];
$surah["no_surah"] = $result["number"];
$surah["nama_surah"] = $result["name"]["transliteration"]["id"];
$surah["nama_surah_arab"] = $result["name"]["short"];
$surah["arti_surah"] = $result["name"]["translation"]["id"];
$surah["turun_surah"] = $result["revelation"]["id"];
$surah["ayat_surah"] = $result["numberOfVerses"];
$surah["tafsir_surah"] = $result["tafsir"]["id"];
$surah["bismillah"] = $result["preBismillah"];
if ($result["preBismillah"]) {
$surah["text_bismillah"] = $result["preBismillah"]["text"]["arab"];
$surah["arti_bismillah"] = $result["preBismillah"]["translation"]["id"];
$surah["audio_bismillah"] = $result["preBismillah"]["audio"]["primary"];
}
$i = 0;
foreach ($result["verses"] as $result) {
$surah["ayat"][$i]["no_ayat"] = $result["number"]["inSurah"];
$surah["ayat"][$i]["text_ayat"] = $result["text"]["arab"];
$surah["ayat"][$i]["arti_ayat"] = $result["translation"]["id"];
$surah["ayat"][$i]["audio_ayat"] = $result["audio"]["primary"];
$surah["ayat"][$i]["tafsir_ayat"] = $result["tafsir"]["id"]["short"];
$i++;
}
return $surah;
}