PHP Advanced Filters
Check whether a number is within a range
The example below uses the filter_var() function to check whether an INT variable is within 1 to 200:
Example
array ( "min_range" => $min , "max_range" => $max ) ) ) === false ) { echo ( "variable value is not within the valid range" ) ; } else { echo ( "variable value is within the valid range" ) ; } ?>Try it »
Check an IPv6 Address
The example below uses the filter_var() function to check whether a $ip variable is an IPv6 address:
Example
Try it »
Remove Characters with ASCII Value Greater Than 127
The example below uses the filter_var() function to remove characters in a string with ASCII value greater than 127; it can also remove HTML tags:
Example
Hello WorldÆØÅ!" ; $newstr = filter_var ( $str , FILTER_SANITIZE_STRING , FILTER_FLAG_STRIP_HIGH ) ; echo $newstr ; ?>Try it »
PHP Filter Reference
You can also visit our PHP Filter Reference to view specific applications of the filters.
The reference manual contains brief descriptions and usage examples of the filter parameters!