php class F_FileIterator extends FilterIterator private ext function _

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
class F_FileIterator extends FilterIterator {
private $ext;
function __construct(DirectoryIterator $it,$ext) {
parent::__construct($it);
$this->ext=$ext;
}
function accept() {
return in_array((pathinfo($this->current(),PATHINFO_EXTENSION)),$this->ext);
}
}
$d=new F_FileIterator(new DirectoryIterator('ПУТЬ ДО ПАПКИ'), array('gif','png','jpg','jpeg'));
$count=0;
foreach ($d as $v) {
$count++;
}
echo "В папке $count графических файлов";
?>