note 106212 added to function.glob
| From: | http://www dot binh dot me at osu1 dot php dot net | Date: | Wed, 19 Oct 2011 07:33:05 +0000 |
| Subject: | note 106212 added to function.glob | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-183985@lists.php.net to get a copy of this message | ||
Using glob for counting file name is taking much longer time and more resources. Even though
it's short one line of code to count file, but using for loop
Tested on http://www.meo.vn these 2 code for counting cache files
$glob = glob(CACHEPATH . "*.dat");
if ($glob) $count = count($glob);
AND
if ($handle = @opendir(CACHEPATH))
{
while ($file = readdir($handle))
{
if ($file != '.' && $file != '..')
{
$count++;
}
}
closedir($handle);
}
RESULT
Only 1 file in that directory
glob took about 5 seconds to return
readdir took 1 second
----
Server IP: 69.147.83.197
Probable Submitter: 117.6.129.73
----
Manual Page -- http://www.php.net/manual/en/function.glob.php
Edit -- https://master.php.net/note/edit/106212
Del: integrated -- https://master.php.net/note/delete/106212/integrated
Del: useless -- https://master.php.net/note/delete/106212/useless
Del: bad code -- https://master.php.net/note/delete/106212/bad+code
Del: spam -- https://master.php.net/note/delete/106212/spam
Del: non-english -- https://master.php.net/note/delete/106212/non-english
Del: in docs -- https://master.php.net/note/delete/106212/in+docs
Del: other reasons-- https://master.php.net/note/delete/106212
Reject -- https://master.php.net/note/reject/106212
Search -- https://master.php.net/manage/user-notes.php