(PHP 5 >= 5.4.0, PHP 7)
Examples:
Available callback arguments

The callback should accept up to three arguments: the current item, the current key and the iterator, respectively.

<?php

/**
 * Callback for CallbackFilterIterator
 *
 * @param $current   Current item's value
 * @param $key       Current item's key
 * @param $iterator  Iterator being filtered
 * @return boolean   TRUE to accept the current item, FALSE otherwise
 */
function my_callback($current, $key, $iterator) {
    // Your filtering code here
}

?>

Callback basic examples

Any callable may be used; such as a string containing a function name, an array for a method, or an anonymous function.

<?php

$dir = new FilesystemIterator(__DIR__);

// Filter large files ( > 100MB)
function is_large_file($current) {
    return $current->isFile() && $current->getSize() > 104857600;
}
$large_files = new CallbackFilterIterator($dir, 'is_large_file');

// Filter directories
$files = new CallbackFilterIterator($dir, function ($current, $key, $iterator) {
    return $current->isDir() && ! $iterator->isDot();
});

?>

CallbackFilterIterator::__construct

(PHP 5 >= 5.4.0, PHP 7) Create a filtered iterator from another iterator

2016-02-24 16:19:45
CallbackFilterIterator::accept

(PHP 5 >= 5.4.0, PHP 7) Calls the callback with the current value, the current key and the inner iterator

2016-02-24 16:19:45