In this post i am going to write about Converting Currency using Google Finance Using php Scripting Language, we Can Convert Currency using Google finance very easily it will take 3 inputs namely from,to,amount, along with this 3 inputs we will send HTTP request to Google Finance using CURL, then we will get the amount value converted in given currency .
Complete full Code
Invalid amount."; } elseif($from == $to) { $content .= "Please select distinct currencies.
"; } else { $rawData = currencyConvert($from,$to,$amount); $regex = '#(.+?)#s'; preg_match($regex, $rawData, $converted); $result = isset($converted[0]) ? $converted[0] : "" ; if($result == "") { $content .= "Exchange Rate not available.
"; } else { $content .= "".$amount." ".$from." = ".$result."
"; } } } function currencyConvert($from,$to,$amount){ $url = "http://www.google.com/finance/converter?a=$amount&from=$from&to=$to"; $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_USERAGENT,"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)"); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 0); $response = curl_exec($ch); curl_close($ch); return $response; } ?>Convert Currency using Google Finance Convert Currency using Google Finance in PHP Demo