PHP Function Reference

PHP filter_list() Function



The PHP filter_list() function returns a list of all supported filters.

Syntax

filter_list()

Parameters

No parameter is required.

Return Value

Returns an array of names of all supported filters, empty array if there are no such filters. Indexes of this array are not filter IDs. It can be obtained using filter_id() function using filter name.

Example:

In the example below, filter_list() function is used to see all supported filters.

<?php
print_r(filter_list());
?>

The output of the above code will be:

Array
(
    [0] => int
    [1] => boolean
    [2] => float
    [3] => validate_regexp
    [4] => validate_domain
    [5] => validate_url
    [6] => validate_email
    [7] => validate_ip
    [8] => validate_mac
    [9] => string
    [10] => stripped
    [11] => encoded
    [12] => special_chars
    [13] => full_special_chars
    [14] => unsafe_raw
    [15] => email
    [16] => url
    [17] => number_int
    [18] => number_float
    [19] => add_slashes
    [20] => callback
)

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