Last active
February 25, 2017 20:19
-
-
Save rohankhudedev/d5ea7b53408bca65d6a78879c15f586c to your computer and use it in GitHub Desktop.
currency converter google finance calculator can be for all language - php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//I have used google finance calculator for this purpose | |
function convertCurrency($amount, $from, $to){ | |
$url = "https://www.google.com/finance/converter?a=$amount&from=$from&to=$to"; | |
$data = file_get_contents($url); | |
preg_match("/<span class=bld>(.*)<\/span>/",$data, $converted); | |
$converted = preg_replace("/[^0-9.]/", "", $converted[1]); | |
return round($converted, 3); | |
} | |
//# Call function | |
echo convertCurrency(1, "USD", "INR"); | |
//More info can be found here | |
//http://www.altafweb.com/2013/11/convert-currency-using-google-finance.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment