#40174 [Opn->Bgs]: is_numeric with currency values
| From: | tony2001@php.net | Date: | Fri, 19 Jan 2007 17:14:04 +0000 |
| Subject: | #40174 [Opn->Bgs]: is_numeric with currency values | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-107782@lists.php.net to get a copy of this message | ||
ID: 40174
Updated by: tony2001@php.net
Reported By: sehh at altered dot com
-Status: Open
+Status: Bogus
Bug Type: Math related
Operating System: Fedora Core Linux
PHP Version: 5.2.0
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Previous Comments:
------------------------------------------------------------------------
[2007-01-19 17:07:21] sehh at altered dot com
Description:
------------
The function is_numeric() fails when the input is a value with thousand
and decimal separators.
For example: 4.000,56 or 4,000.56.
We had a short discussion about this in #php irc channel and found out
the following:
"4,000.56" = is USA notation
"4.000,56" = is European notation
They are perfectly valid numeric values, used in currency/weight/cubic
centimeters/etc.
Suggested solutions:
1) Both notations should be accepted.
2) Only one notation should be accepted and PHP will decide which one,
based on the Locale of the server/setup.
Any other suggestion is welcome.
Reproduce code:
---------------
Reproduction code:
<?php
$dolars = "4,000.56";
$euros = "4.000,56";
$rc = is_numeric($dolars);
var_dump($rc);
$rc = is_numeric($euros);
var_dump($rc);
?>
Expected result:
----------------
is_numeric should have returned TRUE in both cases.
Actual result:
--------------
is_numeric returns false for both.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=40174&edit=1