Skip to main content

Posts

Showing posts from December, 2017

Currency Converter with php using Google Api

Currency Converter with php using Google Api Google provides google finance api to convert currency . here is the simple example of currency conversion using google finance API. <?php $from_currency = "USD"; $to_currency = "INR"; $amount = "100.000"; $converted_currency=convertCurrency($from_currency, $to_currency, $amount); echo $converted_currency;  function convertCurrency($from, $to, $amount){     $from = urlencode($from);     $to = urlencode($to);     $data = file_get_contents("https://finance.google.com/finance/converter?a=$amount&from=$from&to=$to");     preg_match("/<span class=bld>(.*)<\/span>/",$data, $converted);     $converted = preg_replace("/[^0-9.]/", "", $converted[1]);     return number_format(round($converted, 3),2); } ?>