Open In App

PHP | filter_list() Function

Last Updated : 11 Feb, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

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:




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


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.




<?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>";
}
  
?>


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


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads