filter_list & filter_id

We can display list of available filters by using filter_list function. This function returns an array with list of available filters as elements. Here is the example.
print_r(filter_list());
The output is here
Array ( [0] => int [1] => boolean [2] => float [3] => validate_regexp
 [4] => validate_url  [5] => validate_email [6] => validate_ip [7] => string
 [8] => stripped [9] => encoded [10] => special_chars 
[11] => full_special_chars [12] => unsafe_raw [13] => email
 [14] => url [15] => number_int
 [16] => number_float [17] => magic_quotes [18] => callback )
Now we will modify it by displaying in a formatted output. We used standard array display techniques to display the elements of the array
Here is the code to display output
$ar=filter_list();
	foreach ($ar as $key => $val) {
echo "$key => $val 
";
The output is here ( Note that the serial number is the key number of the array filter_list not the filter ID number )
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 => add_slashes
21 => callback

filter_id

WE can get the filter id of the particular filter in PHP by using filter_id function. We will input the name of the filter and get the associated id of it. The list containing name of filter is available at filter_list page. Here is the syntax.
Int filter_id(filter name)
Here is one example echo filter_id('validate_url'); The output of above line is here
273
We can also display the associated id of all the filters in a single list. Here is the sample code.
$ar=filter_list();
while (list ($key, $val) = each ($ar)) { echo "$key -> $val : ( ".filter_id($val). " ) <br>"; }
The output is here
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 -> add_slashes : ( 523 )
21 -> callback : ( 1024 )

Questions


Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com







    Post your comments , suggestion , error , requirements etc here





    PHP video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer