Created
November 22, 2016 05:52
-
-
Save iegik/0f2e559984644450d125528f5921d33e to your computer and use it in GitHub Desktop.
USD and EUR from Central Bank of Russia
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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