PHP FILTER_CALLBACK Filter
Complete PHP Filter Reference
Definition and Usage
The FILTER_CALLBACK filter calls a user defined function to filter the value.
This filter gives us full control over the data filtering
The specified functions must be in an
associative array with the name "options". See example below
- Name: "callback"
- ID-number: 1024
Tips and Notes
Tip: You can create your own user defined function or use an existing
PHP function
Example 1
Using a user defined function:
<?php
function convertSpace($string)
{
return str_replace(" ", "_", $string);
}
$string = "Peter is a great guy!";
echo filter_var($string, FILTER_CALLBACK,
array("options"=>"convertSpace"));
?>
|
The output of the code will be:
Example 2
Using an existing PHP function
<?php
$string="Peter is a great guy!";
echo filter_var($string, FILTER_CALLBACK,
array("options"=>"strtoupper"));
?>
|
The output of the code will be:
Complete PHP Filter Reference

Need an easy way to get data into XML, or transform XML to another format?
MapForce lets you map XML data to/from any combination of XML, database, flat file,
Excel 2007, XBRL, or Web services data. Then it transforms data instantly or
auto-generates royalty-free code for recurrent conversions.
New features in Version 2010!
- Easy-to-use, graphical data mapping interface
- Instant data transformation
- XSLT 1.0/2.0 and XQuery code generation
- Java, C#, and C++ code generation
- Advanced data processing functions
- Support for all major relational databases including SQL Server, IBM DB2, Oracle, and more
- Visual Studio & Eclipse integration
- Available in 32-bit and 64-bit versions
Download a fully-functional trial today!
|
|
|
|