<?php
class F_FileIterator extends FilterIterator {
private $ext;
private $it;
function __construct(DirectoryIterator $it, $ext) {
parent::__construct($it);
$this->it=$it;
$this->ext=$ext;
}
function accept() {
$ext=pathinfo($this->current(),PATHINFO_EXTENSION);
return ($ext==$this->ext) ? true : false;
}
}
$d=new F_FileIterator(new DirectoryIterator('.'), 'php');
foreach ($d as $v) {
echo "$v<br />\n";
}
?>