Re: Converting floats to ints with intval
| From: | David Otton | Date: | Thu, 06 May 2010 11:09:31 +0000 |
| Subject: | Re: Converting floats to ints with intval | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-304949@lists.php.net to get a copy of this message | ||
On 6 May 2010 11:52, Paul Waring <paul@xk7.net> wrote:
> If I was designing the system from scratch, that's what I'd do.
> Unfortunately this is an add-on to a legacy system where currency values are
> already stored as strings in the database (yes, not ideal I know, but you
> have to work with what you've got).
I don't know much about your situation, but it does sound like you
need to fix the root problem. I'd use a decimal type, and lean on the
database to do the maths.
http://dev.mysql.com/doc/refman/5.1/en/numeric-types.html
You many also find money_format() useful:
http://php.net/manual/en/function.money-format.php