filter_var

PHP Filter Function: filter_var

Support PHP version

  • PHP 5 >= 5.2.0
  • PHP 7
  • PHP 8

Example

Get just number from the given string

$a = '!a-b.c3@j+dk9.0$3e8`~]\]2';
$number = str_replace(['+', '-'], '', filter_var($a, FILTER_SANITIZE_NUMBER_INT));
// Output is 390382

Reference

Example