Latest web development tutorials
 

PHP filter_id() Function

< PHP Filter Reference

Example

Return the filter ID of the VALIDATE_EMAIL filter:

<?php
$echo(filter_id("validate_email"));
?>
Run example »

Definition and Usage

The filter_id() function returns filter ID of a specified filter name.


Syntax

filter_id(filter_name)
Parameter Description
filter_name Required. The filter name to get the id from. Tip: Use the filter_list() function to list the names of all available filters

Technical Details

Return Value: Returns the filter ID on success, or FALSE if the filter does not exist
PHP Version: 5.2.0+

More Examples

Example 1

The filter_list() function can be used to list the name and ID of all available filters:

<table>
  <tr>
    <td>Filter Name</td>
    <td>Filter ID</td>
  </tr>
  <?php
  foreach (filter_list() as $id =>$filter) {
    echo '<tr><td>' . $filter . '</td><td>' . filter_id($filter) . '</td></tr>';
  }
?>
</table>
Run example »

< PHP Filter Reference