PHP | filter_list() Function

The filter_list() function is an inbuilt function in PHP which is used to returns the list of all supported filters.

Syntax:

array filter_list( void )

Parameters: This function does not accepts any parameters.



Return Values: It returns an array containing all names of supported filters. If it returns an empty array then it does not contains any filters. The filter id can be obtained by filter_id() function.

Note: This function available for PHP 5.2.0 and newer versions.

Below examples illustrate the filter_id() function in PHP:

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

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] => magic_quotes
    [20] => callback
)

Example 2: It display the associated id of all the filters in a single list.

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Array filter function assign to a variable
$arr = filter_list();
  
// Use loop to display the key and its value
while (list ($key, $val) = each ($ar2)) {
echo "$key -> $val : ( ".filter_id($val). " ) <br>";
}
  
?>

chevron_right


Output:

0 -> int : ( 257 ) 
1 -> boolean : ( 258 )
2 -> float : ( 259 )
3 -> validate_regexp : ( 272 )
4 -> validate_domain : ( 277 )
5 -> validate_url : ( 273 )
6 -> validate_email : ( 274 )
7 -> validate_ip : ( 275 )
8 -> validate_mac : ( 276 )
9 -> string : ( 513 )
10 -> stripped : ( 513 )
11 -> encoded : ( 514 )
12 -> special_chars : ( 515 )
13 -> full_special_chars : ( 522 )
14 -> unsafe_raw : ( 516 )
15 -> email : ( 517 )
16 -> url : ( 518 )
17 -> number_int : ( 519 )
18 -> number_float : ( 520 )
19 -> magic_quotes : ( 521 )
20 -> callback : ( 1024 )

References: http://php.net/manual/en/function.filter-list.php



My Personal Notes arrow_drop_up

I am a programmer by hobby

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.