Tag Archives: Filter

FILTER_SANITIZE_NUMBER_FLOAT

Remove all illegal characters from a float number

Example
======

<?php
echo filter_var(“1-7php+5.4Codez”, FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
?>

Output
=====

1-7+5.4

Possible flags:

FILTER_FLAG_ALLOW_SCIENTIFIC – Separate fraction with e and E)

FILTER_FLAG_ALLOW_FRACTION – Separate fraction with “.”
FILTER_FLAG_ALLOW_THOUSAND – Separate fraction with “,”