PHP FILTER_SANITIZE_NUMBER_FLOAT filter
Definition and Usage
FILTER_SANITIZE_NUMBER_FLOAT filters to remove a floating-point number in all illegal characters.
The filter is enabled by default for all Digital + and -
- Name: "number_float"
- ID-number: 520
Possible signs:
- FILTER_FLAG_ALLOW_FRACTION - Allow the decimal separator (for example.)
- FILTER_FLAG_ALLOW_THOUSAND - allow thousands separator (for example,)
- FILTER_FLAG_ALLOW_SCIENTIFIC - Allow scientific notation (such as e and E)
Examples
<?php
$number="5-2f+3.3pp";
var_dump(filter_var($number, FILTER_SANITIZE_NUMBER_FLOAT,
FILTER_FLAG_ALLOW_FRACTION));
?>
$number="5-2f+3.3pp";
var_dump(filter_var($number, FILTER_SANITIZE_NUMBER_FLOAT,
FILTER_FLAG_ALLOW_FRACTION));
?>
Output code is as follows:
string(7) "5-2+3.3"
Complete PHP Filter Reference