note 106212 deleted from function.glob by danbrown

From: Date: Wed, 19 Oct 2011 12:42:26 +0000
Subject: note 106212 deleted from function.glob by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-183991@lists.php.net to get a copy of this message
Note Submitter: http://www.binh.me ---- 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

« previous php.notes (#183991) next »