note 102660 deleted from function.glob by danbrown

[email protected] Sun, 27 Feb 2011 08:19:00 -0800
Newsgroups php.notes
Message-ID <[email protected]>
Note Submitter: White-Gandalf at web dot de 

----

Regarding the so called "fastest way":

"glob" is up to ten (!) times slower than any other internal php function! If you are really interested in FAST directory walking, use "scandir" instead!

Try it for yourself!

$t0 = microtime(true);
$files = glob($path.'/*');
$t1 = microtime(true);
echo "glob('".$path."/*') : ".($t1 - $t0)."\r\n";
print_r($files);

$t0 = microtime(true);
$files = scandir($path);
$t1 = microtime(true);
echo "scandir('".$path."'): ".($t1 - $t0)."\r\n";
print_r($files);