<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
// php ile doviz kuru
// e : bugrakaan@gmail.com
// edit : goktug.ozturk [at] hurbilisim.com
$currency = array( "USD" => "", "EUR" => "", "AUD" => "" );
$convert = array( "isim" => "I",
"forexbuying" => "A",
"forexselling" => "S",
);
$content = file_get_contents("https://www.tcmb.gov.tr/kurlar/today.xml");
foreach($currency as $code => $arr){
preg_match("'<currency Kod=\"(".$code.")\".*>(.*)</currency>'Uis",$content,$crst);
foreach($convert as $field => $value){
preg_match("'<".$field.">(.*)</".$field.">'Uis",$crst[2],$frst);
$currency[$code][$value] = $frst[1];
}
}
?>
<table width="200" border="1">
<tr>
<td>Döviz</td>
<td>Alış</td>
<td>Satış</td>
</tr>
<tr>
<td>Dolar</td>
<td><?=$currency['USD']['A']?></td>
<td><?=$currency['USD']['S']?></td>
</tr>
<tr>
<td>Euro</td>
<td><?=$currency['EUR']['A']?></td>
<td><?=$currency['EUR']['S']?></td>
</tr>
<tr>
<td>Avustralya Doları</td>
<td><?=$currency['AUD']['A']?></td>
<td><?=$currency['AUD']['S']?></td>
</tr>
</table>
<br>
</body>
</html>