Displaying a Central Bank exchange rate with PHP

Posted: 26-05-2019 | Views: 152
Displaying a Central Bank exchange rate with PHP

Create a php file and enter the codes here

$a = date("d.m.Y");
$url = 'https://www.cbar.az/currencies/' .$a. '.xml';
$xml = simplexml_load_file($url);
if ($xml !== FALSE) {
$Rate = $xml->ValType[1]->Valute[44]->Value;
$Rate2 = $xml->ValType[1]->Valute[38]->Value;
$Rate3 = $xml->ValType[1]->Valute[4]->Value;
$d=$Rate;
$e=$Rate2;
$r=$Rate3;
$v="<b>AZN məzənnəsi:</b> </br>";
print ($v);
print($xml->attributes()->Date);
print "</br>tarixdən etibarən</br>";
print "1 USD &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
print "$d</br>";
print "1 EUR &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
print "$e</br>";
print "1 RUB &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
print "$r";
}

Add comment