Currency Converter in PHP

$encode_amount = 1;
$amount = 100;
$from_Currency = ‘INR’;
$to_Currency = ‘USD’;

$get = file_get_contents(“https://www.google.com/finance/converter?a=$encode_amount&from=$from_Currency&to=$to_Currency”);
$get = explode(“<span class=bld>”,$get);
$get = explode(“</span>”,$get[1]);
$rate= preg_replace(“/[^0-9\.]/”, null, $get[0]);
$converted_amount = $amount*$rate;
$data = array( ‘rate’ => $rate, ‘converted_amount’ =>$converted_amount, ‘from_Currency’ => strtoupper($from_Currency), ‘to_Currency’ => strtoupper($to_Currency));

 

Array
(
    [rate] => 0.0147
    [converted_amount] => 1.47
    [from_Currency] => INR
    [to_Currency] => USD
)

 

 

Advertisements
Posted in PHP

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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