I need to filter the value like this 100.50 using filter_var in PHP.
Now I am using like this
filter_var($_POST['amount'],FILTER_SANITIZE_NUMBER_INT) : '';
And it gives me the result is 10050 .
How can I solve this problem.
Thanks in advance.
I need to filter the value like this 100.50 using filter_var in PHP. Now
Share
An integer does not have decimal fractions, so the validation must fail (although I find the sanitation result of
100.50turning into10050pretty bizarre on PHP’s end. WTF?).You would need to use a different filter, e.g.
FILTER_VALIDATE_FLOAT.List of PHP validate filters