Skip to content

Instantly share code, notes, and snippets.

@Mashpy
Created March 18, 2015 09:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save Mashpy/db6f6657519a9364d6d8 to your computer and use it in GitHub Desktop.
Save Mashpy/db6f6657519a9364d6d8 to your computer and use it in GitHub Desktop.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>selected demo</title>
<style>
div {
color: red;
}
</style>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<?php
function get_currency($from_Currency, $to_Currency, $amount) {
$amount = urlencode($amount);
$from_Currency = urlencode($from_Currency);
$to_Currency = urlencode($to_Currency);
$url = "http://www.google.com/finance/converter?a=$amount&from=$from_Currency&to=$to_Currency";
$ch = curl_init();
$timeout = 0;
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, $timeout);
$rawdata = curl_exec($ch);
curl_close($ch);
$data = explode('bld>', $rawdata);
$data = explode($to_Currency, $data[1]);
return round($data[0], 2);
}?>
<select>
<option value="default" selected>BDT</option>
<option value="volvo">CAD</option>
<option value="saab">Saab</option>
<option value="vw">VW</option>
<option value="audi" >Audi</option>
</select>
<script>
$( "select" )
.change(function() {
var str = "";
$( "select option:selected" ).each(function() {
str += $( this ).text() + " ";
});
$( ".mashpy" ).text( str );
})
.trigger( "change" );
</script>
<?php
echo $currency = '<div class="mashpy">BDT</div>';
echo $currency1 = strip_tags($currency);
?>
</body>
</html>
@MaxGuam
Copy link

MaxGuam commented Oct 31, 2017

the code needs to be updated, to today's date it does not work

@MaxGuam
Copy link

MaxGuam commented Nov 24, 2017

you need to change the address
$url = "https://finance.google.com/finance/converter?a=$amount&from=$from_Currency&to=$to_Currency";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment