Skip to content

Instantly share code, notes, and snippets.

@Majkl578
Created September 21, 2010 22:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Majkl578/895ea775ab425288aab1 to your computer and use it in GitHub Desktop.
Save Majkl578/895ea775ab425288aab1 to your computer and use it in GitHub Desktop.
<?php
clearstatcache();
$s = microtime(TRUE);
$iterator = new RegexIterator(new DirectoryIterator('/tmp/test'), '~^\d+x$~'); // filtrování ve složce /foo/bar na základě PCRE regulárního výrazu pro název souboru/složky
if (iterator_count($iterator)) { // pokud existuje alespoň 1 záznam
foreach ($iterator as $item) { //procházení
if ($item->isDot() || $item->getFilename() === '.htaccess' || $item->getFilename() === '.ftpaccess') continue; //přeskočit ., .. a ty 2 soubory
echo $item->getFilename(), "\n";
}
} else { // pokud neexistuje nic
echo 'Nenalezeny žádné položky';
}
var_dump(microtime(TRUE) - $s);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment