note 102931 added to function.glob

From: Date: Tue, 15 Mar 2011 14:32:05 +0000
Subject: note 102931 added to function.glob
Groups: php.notes 
Request: Send a blank email to php-notes+get-177898@lists.php.net to get a copy of this message
Don't use glob() if you try to list files in a directory where very much files are stored (>100.000). You get an "Allowed memory size of XYZ bytes exhausted ..." error. You may try to increase the memory_limit variable in php.ini. Mine has 128MB set and the script will still reach this limit while glob()ing over 500.000 files. The more stable way is to use readdir() on very large numbers of files: <?php // code snippet if ($handle = opendir($path)) { while (false !== ($file = readdir($handle))) { // do something with the file // note that '.' and '..' is returned even } closedir($handle); } ?> ---- Server IP: 217.160.235.204 Probable Submitter: 84.184.93.212 ---- Manual Page -- http://www.php.net/manual/en/function.glob.php Edit -- https://master.php.net/note/edit/102931 Del: integrated -- https://master.php.net/note/delete/102931/integrated Del: useless -- https://master.php.net/note/delete/102931/useless Del: bad code -- https://master.php.net/note/delete/102931/bad+code Del: spam -- https://master.php.net/note/delete/102931/spam Del: non-english -- https://master.php.net/note/delete/102931/non-english Del: in docs -- https://master.php.net/note/delete/102931/in+docs Del: other reasons-- https://master.php.net/note/delete/102931 Reject -- https://master.php.net/note/reject/102931 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#177898) next »