<?php
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,'http://www.e-solat.gov.my/solat.php?kod=sgr03&lang=ENG');
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
if (empty($buffer)) {
print '<a href="http://www.e-solat.gov.my/">Prayer Time</a>';
} else {
$waktu_s = array('imsak', 'subuh', 'syuruk', 'zohor', 'asar', 'maghrib', 'isyak');
$w = array();
foreach ($waktu_s as $waktu) {
$w[] = "<tr.*?>.*?<td.*?>.*?$waktu.*?<\/td>.*?<td.*?>.*?(?P<
$waktu>\d?\d:\d\d).*?<\/td>.*?<\/tr>";
}
$t = join(".*?", $w);
$regex = "/<table.*?>.*?$t.*?<\/table>/si";
$result = "";
if (preg_match($regex, $buffer, $matches)) {
$result = '<table border="1"><caption>Kuala Lumpur</caption>';
$result .= '<thead><tr>';
foreach ($waktu_s as $waktu) {
$result .= "<th>".ucfirst($waktu)."</th>";
}
$result .= '</tr></thead>';
$result .= '<tbody><tr>';
foreach ($waktu_s as $waktu) {
$result .= "<td>".$matches[$waktu]."</td>";
}
$result .= '</tr></tbody>';
$result .= '</table>';
}
print $result;
}
?>
Example of output as below:
Imsak | Subuh | Syuruk | Zohor | Asar | Maghrib | Isyak |
---|---|---|---|---|---|---|
5:29 | 5:39 | 6:58 | 13:00 | 16:19 | 18:58 | 20:09 |
I'll leave to you as exercise to show the date of prayer times, GMT and qiblat direction.
3 comments:
Or you could always install this : http://osdir.com/ml/internationalization.arabeyes.general/2006-12/msg00013.html
lowks
http://lowks.inigo-tech.com/blog
Ass Wr Wb
Di tempat saya kota Madiun - Indonesia waktunya +7.00 bagaimana membuat waktu sholat (time prayer)
Sebelumnya diucapkan banyak terima kasih.
Salam dari Indonesia
Wass.
The Islamic Tools and Libraries
Post a Comment