Google News
logo
PHP Program to Use filter_list() to list what the PHP filter extension offers
In the following example of PHP program that uses the `filter_list()` function to list what the PHP filter extension offers :
Program :
<?php
// Get a list of available filters
$filters = filter_list();

// Loop through the filters and print their names and IDs
foreach ($filters as $id => $filter) {
    echo "Filter ID: " . $id . "\n";
    echo "Filter Name: " . $filter . "\n\n";
}
?>
Output :
Filter ID: 0
Filter Name: int

Filter ID: 1
Filter Name: boolean

Filter ID: 2
Filter Name: float

Filter ID: 3
Filter Name: validate_regexp

Filter ID: 4
Filter Name: validate_domain

Filter ID: 5
Filter Name: validate_url

Filter ID: 6
Filter Name: validate_email

Filter ID: 7
Filter Name: validate_ip

Filter ID: 8
Filter Name: validate_mac

Filter ID: 9
Filter Name: string

Filter ID: 10
Filter Name: stripped

Filter ID: 11
Filter Name: encoded

Filter ID: 12
Filter Name: special_chars

Filter ID: 13
Filter Name: full_special_chars

Filter ID: 14
Filter Name: unsafe_raw

Filter ID: 15
Filter Name: email

Filter ID: 16
Filter Name: url

Filter ID: 17
Filter Name: number_int

Filter ID: 18
Filter Name: number_float

Filter ID: 19
Filter Name: add_slashes

Filter ID: 20
Filter Name: callback
This program retrieves a list of available filters using the `filter_list()` function and then loops through them to print out their names and IDs. The output of this program will be a list of all available filters in the PHP filter extension.