Currency Conversion (pounds)
This function will take a value in pounds and a country and will convert the pounds to the currency of the country . Note this function has the currency exchange rates of 23/07/2001 , if you wished to use this on your site you would have to update this every day at least . This would be easy to convert so you could convert from dollars to other currencies .
We used the currency exchange info from this site
Valid countries are us , japan , france , italy , canada , germany and australia
Here is our function
<?php
function ConvPounds($pounds , $country)
{
$rate = 0;
switch($country)
{
Case "us" :
$rate = 1.41973 ;
break;
Case "japan" :
$rate = 176.154 ;
break;
Case "france" :
$rate = 10.7552 ;
break;
Case "italy" :
$rate = 317475 ;
break;
Case "canada" :
$rate = 2.19297 ;
break;
Case "germany" :
$rate = 3.20583 ;
break;
Case "australia" :
$rate = 2.79862 ;
break;
default :
$rate = 0;
break;
}
return $pounds * $rate;
}
?>
And here is our test script
<?php
//test our function
//convert 10 pounds to us dollars
echo ConvPounds(10 , "us");
echo "<br>";
//convert 25 pounds to french francs
echo ConvPounds(25 , "france");
?> |