How to use FILTER SANITIZE NUMBER FLOAT in PHP
This article describe about FILTER_SANITIZE_NUMBER_FLOAT Filter in PHP.
FILTER_SANITIZE_NUMBER_FLOAT Filter
For remove all illegal characters from a float number used FILTER_SANITIZE_NUMBER_FLOAT.
By default this filter allows digit and + -
- Name: "number_float"
- ID-number: 520
Possible flags:
- FILTER_FLAG_ALLOW_THOUSAND - Allow thousand separator (like , )
- FILTER_FLAG_ALLOW_SCIENTIFIC - Allow scientific notation (like e and E)
- FILTER_FLAG_ALLOW_FRACTION - Allow fraction separator (like . )
Example
<html>
<body>
<?php
$number="9-3f+5.3abcdf";
var_dump(filter_var($number, FILTER_SANITIZE_NUMBER_FLOAT,
FILTER_FLAG_ALLOW_FRACTION));
?>
</body>
</html> |
Output

You may also want to read these related articles Click here
Ask Your Question
Got a programming related question? You may want to post your question here
Programming Answers here