Last active
August 29, 2015 13:56
-
-
Save joomdonation/9070854 to your computer and use it in GitHub Desktop.
PHP code to get currency exchange rate
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 | |
| public static function currencyImport($from, $to) | |
| { | |
| $url = 'http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s=' . $from . $to . '=X'; | |
| $handle = @fopen($url, 'r'); | |
| if ($handle) | |
| { | |
| $result = fgets($handle, 4096); | |
| fclose($handle); | |
| } | |
| $currencyData = explode(',', $result); | |
| return $currencyData[1]; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment