PHP filter_id() Function
The PHP filter_id() function returns the filter ID belonging to a named filter.
Syntax
filter_id(name)
Parameters
name |
Required. Specify the name of a filter to get the id from. The list of all supported filters name can be obtained using filter_list() function. |
Return Value
Returns the ID of a filter on success or false if filter does not exist.
Example:
In the example below, filter_id() function is used to find the ID of validate_email filter.
<?php print_r(filter_id('validate_email')); ?>
The output of the above code will be:
274
Example:
In the example below, filter_id() function is used with filter_list() function to find all out the filter ID of all supported filters.
<?php foreach (filter_list() as $id => $filter) { $result[$filter] = filter_id($filter); } print_r($result); ?>
The output of the above code will be:
Array ( [int] => 257 [boolean] => 258 [float] => 259 [validate_regexp] => 272 [validate_domain] => 277 [validate_url] => 273 [validate_email] => 274 [validate_ip] => 275 [validate_mac] => 276 [string] => 513 [stripped] => 513 [encoded] => 514 [special_chars] => 515 [full_special_chars] => 522 [unsafe_raw] => 516 [email] => 517 [url] => 518 [number_int] => 519 [number_float] => 520 [add_slashes] => 523 [callback] => 1024 )
❮ PHP Filter Reference