>>>>> "c" == christian  <[EMAIL PROTECTED]> writes:

 > does anyone know of a way to currency conversions with php? i want
 > to grab the current currency from some kind of web site and then
 > convert money to different currency value

I'm sure plenty of people have done this properly, but here's a
quick hack to use Xe's currency converter.


<?php

class currency 
{

  function convert($amount, $from, $to) {
    
    $regex = "/[0-9.]+\s*$from\s*=\s*([0-9.]+)\s*$to/";

    $return = file ("http://www.xe.net/ucc/convert.cgi?Amount=1&From=$from&To=$to");

    foreach ($return as $line) {
      if( preg_match($regex, $line, $match) ) break;
    }

    if (!isset($match)) return false;

    return $amount * $match[1];

  }

}

$money = new currency;

print $money->convert( 10, "GBP", "AUD" );

?>


-- 
Robin Vickery.................................................
BlueCarrots, 14th Floor, 20 Eastbourne Terrace, London, W2 6LE

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to