Currency Exchange Script Toss

0 replies
I needed a simple little script for currency exchange so i just wrote one real quick. Feel free to use, change, or whatever ...

All it does is connect to google currency converter and grabs the static data I'm looking for. To change which currency to exchange and the amount you can change the options at the top. I didn't need it for all currencies so I made it this way. I could make drop down menus if anyone would be interested. Peace


Code:
<?PHP
$amount = 1;
$from = USD;
$to = MXN;
$time = stream_context_create(array(
    'http' => array('timeout' => 1))); 
$hold = file_get_contents("http://www.google.com/finance/converter?a=$amount&from=$from&to=$to", 0, $time);
$res = preg_match("/<span class=bld>(.*)<\/span>/",$hold,$match);
$result = $match[1];
$final = preg_replace('#\D*?(\d+(\.\d+)?)\D*#','$1',$result);
echo "<center><font size='+1'>Current Exchange: Mexico</font><br> $amount $from = <b> $final pesos</b></center>";
?>
#currency #exchange #script #toss

Trending Topics