Skip to content

Instantly share code, notes, and snippets.

@luckydevilru
Created June 5, 2020 15:28
Show Gist options
  • Select an option

  • Save luckydevilru/3a7f2ea073f59b3860ddea988ab0a55f to your computer and use it in GitHub Desktop.

Select an option

Save luckydevilru/3a7f2ea073f59b3860ddea988ab0a55f to your computer and use it in GitHub Desktop.
Курсы валют из центробанка на php
<?php
function get_currencies() {
$xml = simplexml_load_file('http://cbr.ru/scripts/XML_daily.asp');
$currencies = array();
foreach ($xml->xpath('//Valute') as $valute) {
$currencies[(string)$valute->CharCode] = (float)str_replace(',', '.', $valute->Value);
}
return $currencies;
}
// Получить курс валют доллара и евро
$currencies = get_currencies();
$eur = $currencies['EUR']*1.02; // 70.90
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment