note 15279 added to function.doubleval
| From: | bjoern at syltonline dot de | Date: | Tue, 04 Sep 2001 14:24:35 +0000 |
| Subject: | note 15279 added to function.doubleval | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-17606@lists.php.net to get a copy of this message | ||
If you read double or float val from DB, i.e. MySQL, u get a String first.
now, if you want to convert it to double, doubleval is a good choice.
But if u program in different languages, say german for example, and have set locale settings, like
with
setlocale ("LC_ALL", "de_DE");
you got a problem, becaus in some cases, the decimal point differs from MySQL format, so that
doubleval() returns only the before-decimal-point value.
to work around this, replace the '.' from MySQL with the local decimal point first.
$locale_info = localeconv();
$preis = str_replace(".", $locale_info["decimal_point"], $preis);
Gee, this one was a bastard to find out...
Greetings.
Björn Andersen
http://www.php.net/manual/en/function.doubleval.php