PDA

View Full Version : Currency exchange


iogames
11-19-2011, 02:53 PM
Hi...

I placed a currency exchange by google to automatically check the exchange rate for the euro, everything works Ok, but I've been struggling to add an operation to the code...

<?php
require_once("gcc.php");

$ccy = new gcc();
print round($ccy->get_ccy("USD", "EUR", 1), 2);
?>

I get the right exchange, but I need to discount 0.5 cents to the result, to match what TV and Newspapers rate, those 5 cents are banks fees...
in the operation '1' goes for the unit, and '2' for the decimals...

Any ideas? I've tried lots of variants...

kh99
11-19-2011, 09:14 PM
Do you want a 0.5 cent discount (half a cent) or 5 cents?

Assuming it's 0.5 cents, I think you want this:

print round(($ccy->get_ccy("USD", "EUR", 1) - 0.005), 2);

LifesGreatestGift
11-19-2011, 11:11 PM
Nvm

iogames
11-20-2011, 07:21 PM
Thanks! [it was 0.05 btw]
<?php
require_once("gcc.php");

$ccy = new gcc();
print round(($ccy->get_ccy("USD", "EUR", 1) - 0.05), 2);

print round(($ccy->get_ccy("USD", "EUR", 1) - 0.15), 2);
?>

Last question, how can add a label/tag lets say:

<?php
require_once("gcc.php");

$ccy = new gcc();
print round(($ccy->get_ccy("USD", "EUR", 1) - 0.05), 2); Sale

print round(($ccy->get_ccy("USD", "EUR", 1) - 0.15), 2); Buy
?>

Thx!

kh99
11-20-2011, 09:26 PM
You mean you just want that word to print out after the amount? You could do this:

print round(($ccy->get_ccy("USD", "EUR", 1) - 0.05), 2) . " Sale";