Thread: Why euro?
View Single Post
  #20  
Old 06-17-2008, 08:51 PM
Googi Googi is offline
A Serious Epidemic
Googi's Avatar
Join Date: Oct 2001
Location: Canada
Posts: 18,866
Googi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud of
Send a message via AIM to Googi
Quote:
Originally Posted by Mursle View Post
I was thinking that too...but then the dollar exchange rate goes up and down like a yoyo and the numbers might be inacurate.
They can use live rates to do the conversion. It isn't hard to do.

PHP Code:
<?php
//Subscription prices in Euros
$sub1 = 24.00;
$sub2 = 36.00;
$sub3 = 48.00;
$sub4 = 64.00;
//Gets the value of 1 Euro in USD.
$url = "http://finance.google.com/finance/converter?a=1.00&from=EUR&to=USD";
$findcurrstr = "<span class=bld>";
$findcurrstr2 = "&nbsp;USD";
$file = file($url);
//What we're looking for is close to the end of the file, so reverse the array.
$file = array_reverse($file);
foreach (
$file as $value) {
  if (
$pos = strpos($value,$findcurrstr)) {
    
$startpos = $pos + strlen($findcurrstr);
    
$len = strpos($value,$findcurrstr2) - $startpos;
    
$currvalue = substr($value,$startpos,$len);
    break;
  }
}
//Check if something is wrong with $currvalue that would mean something went wrong.
if ($currvalue) {
  if (
is_numeric($currvalue)) {
    
//Display the prices in USD.
    
$sub1usd = number_format($sub1 * $currvalue,2);
    
$sub2usd = number_format($sub2 * $currvalue,2);
    
$sub3usd = number_format($sub3 * $currvalue,2);
    
$sub4usd = number_format($sub4 * $currvalue,2);
    echo 
"2400 Gelats = \$$sub1usd<br>";
    echo 
"4000 Gelats = \$$sub2usd<br>";
    echo 
"5600 Gelats = \$$sub3usd<br>";
    echo 
"8000 Gelats = \$$sub4usd<br>";
  }
}
?>
Not the optimal way of coding it, but illustrates that it's possible.
__________________