Created
March 18, 2015 09:11
-
-
Save Mashpy/db6f6657519a9364d6d8 to your computer and use it in GitHub Desktop.
This file contains 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
<!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> |
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
the code needs to be updated, to today's date it does not work