How to convert INR to Dollar???
Posted: Tue May 04, 2010 2:58 am
Hello all,
I am working on a project where i need to implement a code which can change INR(Indian Rupees) to USD (Dollar).Currently i got a code from net but i am nt able to get the correct exchange rate....i don't knw the problem and need help ...below i am attaching the code please check this
Thanks
Amit
I am working on a project where i need to implement a code which can change INR(Indian Rupees) to USD (Dollar).Currently i got a code from net but i am nt able to get the correct exchange rate....i don't knw the problem and need help ...below i am attaching the code please check this
Code: Select all
<?php
function currency_convert($Amount,$currencyfrom,$currencyto)
{
$buffer=file_get_contents('http://finance.yahoo.com/currency-converter');
preg_match_all('/name=(\"|\')conversion-date(\"|\') value=(\"|\')(.*)(\"|\')>/i',$buffer,$match);
$date=preg_replace('/name=(\"|\')conversion-date(\"|\') value=(\"|\')(.*)(\"|\')>/i','$4',$match[0][0]);
unset($buffer);
unset($match);
$buffer=file_get_contents('http://finance.yahoo.com/currency/converter-results/'.$date.'/'.$Amount.'-'.strtolower($currencyfrom).'-to-'.strtolower($currencyto).'.html');
preg_match_all('/<span class=\"converted-result\">(.*)<\/span>/i',$buffer,$match);
$match[0]=preg_replace('/<span class=\"converted-result\">(.*)<\/span>/i','$1',$match[0]);
unset ($buffer);
return $match[0][0];
}
?>
<?php
echo currency_convert(200,"USD","INR");
?>
Thanks
Amit