Created
June 5, 2020 15:28
-
-
Save luckydevilru/3a7f2ea073f59b3860ddea988ab0a55f to your computer and use it in GitHub Desktop.
Курсы валют из центробанка на php
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 | |
| 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