From PHP sanitize filters, there is one option for sanitizing integers:
FILTER_SANITIZE_NUMBER_INT - delete all characters except digits, plus and minus.
If we use:
filter_var($var2San, FILTER_SANITIZE_NUMBER_INT);
This will clear the points .and commas ,, but the signs are +and -will remain. For example: ++++ --- 1.110,4 <b>m<sup>2</sup></b>disinfected before ++++---111042. Ideally, it filter_varwill return falsewhen the number is 0, that is, the number should be a natural number , or rather a positive integer.
So a FILTER_SANITIZE_NUMBER_NATURALwould be convenient ... Is there a workaround for this, or do I need RegExp?
source
share