Skip to content

Instantly share code, notes, and snippets.

@joomdonation
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save joomdonation/9070854 to your computer and use it in GitHub Desktop.

Select an option

Save joomdonation/9070854 to your computer and use it in GitHub Desktop.
PHP code to get currency exchange rate
<?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