?
Path : /home/admin/domains/happytokorea.com/private_html/currency/ |
Current File : /home/admin/domains/happytokorea.com/private_html/currency/currency.php |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Currency rate</title> <link rel="stylesheet" href="css/currency.css"> </head> <body> <div class="container"> <div style="font-weight:bold;color:#003664;">อัตราแลกเปลี่ยนเงิน</div> <div>ประจำวันที่: <? echo date("m-d-y");?></div> <table border="1" cellpadding="5" style="border-collapse:collapse;width:100%;"> <thead> <tr> <th style=" background-color:#2994c6;color:white;">สกุลเงิน/บาท</th> <th style=" background-color:#2994c6;color:white;">อัตราแลกเปลี่ยนเฉลี่ย</th> </tr> </thead> <tbody> <tr> <td class="currency">KRW</td> <td class="rate"><? echo convertCurrency(1, "KRW", "THB");?></td> </tr> <tr> <td class="currency">JPY</td> <td class="rate"><? echo convertCurrency(1, "JPY", "THB");?></td> </tr> <tr> <td class="currency">USD</td> <td class="rate"><? echo convertCurrency(1, "USD", "THB");?></td> </tr> </tbody> </table> <? function convertCurrency($amount, $from, $to){ $url = "https://www.google.com/finance/converter?a=$amount&from=$from&to=$to"; $data = file_get_contents($url); preg_match("/<span class=bld>(.*)<\/span>/",$data, $converted); $converted = preg_replace("/[^0-9.]/", "", $converted[1]); return round($converted, 3); } ?> </div> </body> </html>