Convert Currency using Google finance calculator with PHP

Convert currency from one country to another easily with Google’s finance calculator, using that it’s possible to collect the output using PHP.

Please check below URL:

Use below code to extract actual curreny from html:

function convertCurrency($amount, $from, $to){
$data = file_get_contents("$amount&from=$from&to=$to");
preg_match("'<span class=bld>(.*?)</span>'si",$data, $converted);
$converted = preg_replace("/[^0-9.]/", "", $converted[1]);
return number_format(round($converted, 3),2);

echo convertCurrency("1.00", "USD", "INR");

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s