Cos I'm actually using this

I have changed another couple of things that may be of interest.
In my construct is now
# make sure we have the latest rates
$this->checkRatesActual();
which looks like this
private function checkRatesActual() {
$filename= 'conversion_rates.json';
if (file_exists($filename)) {
date_default_timezone_set("America/Los_Angeles");
setlocale(LC_TIME, "de_DE");
$nTimestamp = filectime($filename);
$dtime = strftime("%d %b %Y", $nTimestamp);
$str = "now";
$timestamp = strtotime($str);
$now = strftime("%d %b %Y", $timestamp);
if($now > $dtime) {
$this->updateRates();
}
}
}
all this does is check that the date of the file is todays date, otherwise update our rates - yes i know i must add something for the weekends !
I have also added this function
public function str2int($string, $concat = true) {
$value = split('[/.-]', $string);
$string = $value[0].$value[1];
$length = strlen($string);
for ($i = 0, $int = '', $concat_flag = true; $i < $length; $i++) {
if (is_numeric($string[$i]) && $concat_flag) {
$int .= $string[$i];
} elseif(!$concat && $concat_flag && strlen($int) > 0) { $concat_flag = false;
}
}
return (int) $int;
}
which i now call in toCurrency - just to make sure that whatever is passed is usuable
public function toCurrency($fAmount)
{
if(!is_numeric($fAmount)) {
$fAmount = $this->str2int($fAmount);
}
Oh and at the bottem of update rates i have included a touch because on the server i am on the date of the file was not being updated.
eg
$pFile = fopen(self::OPT_FILE, 'w+');
fwrite($pFile, json_encode($aRates));
fclose($pFile);
touch($pFile);
hope that helps someone
