Hi
I'm having an issue echo out the euro currency
sign with the price converted base on the $exchange_rate = 0.7746;
Here is my code:
<?php
$currency = true;
$format = '€ %2f';
$exchange_rate = 0.7746;
function currency_valve($data)
{
$price = $data[1];
$cpercent = $data[2];
$cvalve = isset ($_GLOBALS['currency']) && $_GLOBALS['currency'];
$amount = ($cvalve ) ? $price * (1 + $cpercent / 100) : $price;
return sprintf($GLOBALS['format'], $amount / $GLOBALS['exchange_rate']);
}
$data = "This Mango Cheesecake costs {amount: 11.95} "."and the Raspberry Cheesecake costs {amount: 13.95}.\n";
echo preg_replace_callback ('/\{amount\:\ ([0-9.]+)\ \%([0-9.]+)\%\}/','currency_valve',$data);
?>
When I echo it:
This Mango Cheesecake costs {amount: 11.95} and the Raspberry Cheesecake costs {amount: 13.95}.
It should convert the euro price
/ exchange rate = 0.7746
= new euro price
The correct statement should look like this:
This Mango Cheesecake costs {euro 11.95} and the Raspberry Cheesecake costs {euro 13.95}.
Any Suggestions and explanation will help. I appreciate it. Thanks!