Re: Get directory items, read file lines...

From: Date: Thu, 22 Aug 2002 15:38:18 +0000
Subject: Re: Get directory items, read file lines...
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-113637@lists.php.net to get a copy of this message
Here you go... if( ($dir = @opendir( $path )) ) { while( $aFile = @readdir( $dir ) ) { // // Test you really have a file vs. having a // directory and then do your stuff. // } } A far better approach though, is to familiarize yourself with the appropriate routines: http://www.php.net/manual/en/ref.dir.php http://www.php.net/manual/en/function.file.php Cheers, Rob. --------------------------------------------------------------------------- "Joseph W. Goff" wrote: > > 1) readdir(); > > 2) $your_file = file($filename); $your_line=$your_file[$your_line_number] > > 3) $fp = fopen($filename,'w'); > fputs($fp,$your_text); > fclose($fp); > > In the second argument to fopen, w = write, a = append, r = read > See the manual for more info on these functions. > ----- Original Message ----- > From: "Bill Leonard" <bill@machinemen.com> > To: <php-general@lists.php.net> > Sent: Thursday, August 22, 2002 10:15 AM > Subject: [PHP] Get directory items, read file lines... > > > Hey all, > > > > Pretty new to PHP... A couple of general questions will help me solve a > > larger problem...! > > > > 1) I need to read all of the names of the files in a given directory > > > > 2) read a given line number out of each of these files (just text) > > > > 3) write it to a delimited file of some sort > > > > I think I am on to #2 and #3, but #1 I am having trouble with... Any > > pointers would be appreciated! -- .-----------------. | Robert Cummings | :-----------------`----------------------------. | Webdeployer - Chief PHP and Java Programmer | :----------------------------------------------: | Mail : mailto:robert.cummings@webmotion.com | | Phone : (613) 731-4046 x.109 | :----------------------------------------------: | Website : http://www.webmotion.com | | Fax : (613) 260-9545 | `----------------------------------------------'

« previous php.general (#113637) next »