Way1 :
$from_Currency = urlencode($from);
$to_Currency = urlencode($to);
$encode_amount = $amount;
$get = file_get_contents("https://finance.google.com/bctzjpnsun/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));
$res = round( $data );
way 2 :
$conv_id = "{$from}_{$to}";
$string = file_get_contents("http://free.currencyconverterapi.com/api/v3/convert?q=$conv_id&compact=ultra");
$json_a = json_decode($string, true);
$res = $amount * round($json_a[$conv_id], 4);
$from_Currency = urlencode($from);
$to_Currency = urlencode($to);
$encode_amount = $amount;
$get = file_get_contents("https://finance.google.com/bctzjpnsun/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));
$res = round( $data );
way 2 :
$conv_id = "{$from}_{$to}";
$string = file_get_contents("http://free.currencyconverterapi.com/api/v3/convert?q=$conv_id&compact=ultra");
$json_a = json_decode($string, true);
$res = $amount * round($json_a[$conv_id], 4);
No comments:
Post a Comment