Re: Read directory; store filenames found in mySQL table?
| From: | Rahul S. Johari | Date: | Wed, 13 Jan 2010 15:20:47 +0000 |
| Subject: | Re: Read directory; store filenames found in mySQL table? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-301064@lists.php.net to get a copy of this message | ||
On Jan 13, 2010, at 10:07 AM, Kenneth Sande wrote:
Ashley Sheridan wrote:Considering that I have over 80K files in the folder, would this be a faster/efficient then the readdir() method? Or should I stick to what I'm doing (other email)? --- Rahul Sitaram Johari Founder, Internet Architects Group, Inc. [Email] sleepwalker@rahulsjohari.com [Web] http://www.rahulsjohari.comOn Wed, 2010-01-13 at 09:25 -0500, Rahul S. Johari wrote:I use the glob function in my little homemade "web cam" page, which can really swell up in memory when used against a large amount of files (in my case around 30k files). ===== $imgdir = 'img/south*'; $files = glob( $imgdir ); // Sort files by modified time, latest to earliest // Use SORT_ASC in place of SORT_DESC for earliest to latest array_multisort( array_map( 'filemtime', $files ), SORT_NUMERIC, SORT_DESC, $files ); ===== http://www.php.net/manual/en/function.glob.php DISCLAIMER: I found this code on a how-to somewhere out there and modified it to fit my need. Quite possibly there are much better means to this end. Ken Sande/KC8QNIAve, This is what I'm trying to do; I want to read a directory (eg: W:\Test \) and take all the filenames found in the directory (eg: 1.vox, 2.wav, 3.txt) and store them in a simple mySQL table. Can I do this? --- Rahul Sitaram Johari Founder, Internet Architects Group, Inc. [Email] sleepwalker@rahulsjohari.com [Web] http://www.rahulsjohari.comYou'll probably want to look at the readdir() function. The manual page also has dozens of different example scripts that would be easy to tweak for your purpose. http://php.net/manual/en/function.readdir.php Thanks, Ash http://www.ashleysheridan.co.uk