note 15279 deleted from function.doubleval by sniper
| From: | sniper@php.net | Date: | Sat, 23 Aug 2003 00:25:45 +0000 |
| Subject: | note 15279 deleted from function.doubleval by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-54923@lists.php.net to get a copy of this message | ||
Note Submitter: bjoern@syltonline.de
----
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