Skip to content

Instantly share code, notes, and snippets.

@iegik
Created November 22, 2016 05:52
Show Gist options
  • Save iegik/0f2e559984644450d125528f5921d33e to your computer and use it in GitHub Desktop.
Save iegik/0f2e559984644450d125528f5921d33e to your computer and use it in GitHub Desktop.
USD and EUR from Central Bank of Russia
<?php
$url = 'http://www.cbr.ru/scripts/XML_daily.asp';
$ch = curl_init( $url );
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec( $ch );
curl_close($ch);
$xml = new SimpleXMLElement($result);
foreach ($xml->Valute as $Valute) {
if($Valute->CharCode == 'USD'){
$USD = $Valute;
}
if($Valute->CharCode == 'EUR'){
$EUR = $Valute;
}
}
?>
<table>
<tr>
<td><?=$USD->Name?></td>
<td><?=$USD->Value?></td>
</tr>
<tr>
<td><?=$EUR->Name?></td>
<td><?=$EUR->Value?></td>
</tr>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment