php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #51368 php_filter_float does not allow custom thousand separators
Submitted: 2010-03-23 18:50 UTC Modified: 2018-03-24 14:08 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: mumu at seznam dot cz Assigned: cmb (profile)
Status: Closed Package: Filter related
PHP Version: 5.2.13 OS: N/A
Private report: No CVE-ID: None
 [2010-03-23 18:50 UTC] mumu at seznam dot cz
Description:
------------
The php_filter_float function located in /[svn]/php/php-src/trunk/ext/filter/logical_filters.c does not allow setting custom thousand separators - the function always uses built-in set of three separators provided in the tsd_sep[3] local variable, currently ",.'" (without double quotes).

As a result, the function is not usable in countries which uses other char as a thousand separator, for example " ". Additionally, it does not allow to prohibit separators some of the separators.

Please add support for setting custom thousand separators which will override the one built-in in the source code.

Test script:
---------------
var_dump(filter_var('1 000', FILTER_VALIDATE_FLOAT, array('flags' => FILTER_FLAG_ALLOW_THOUSAND, 'options' => array('thousand' => ' '))));

Expected result:
----------------
float(1000)

Actual result:
--------------
bool(false)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-02-28 19:50 UTC] cmb@php.net
-Package: Unknown/Other Function +Package: Filter related
 [2018-03-24 14:08 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2018-03-24 14:08 UTC] cmb@php.net
The PR has been merged – closing.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Jun 24 15:01:26 2019 UTC