Usage example:
<?php
class AdultFilter extends \FilterIterator
{
public function accept()
{
$person = $this->current();
if (18 <= $person[1]) {
return true;
}
return false;
}
}
$persons = new \ArrayIterator([
['John', 27],
['Jack', 15],
['Jeff', 54],
]);
$adults = new AdultFilter($persons);
foreach ($adults as $adult) {
var_dump($adult);
}