Re: ...And removing one line only?

From: Date: Wed, 21 Mar 2001 02:07:26 +0000
Subject: Re: ...And removing one line only?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-44859@lists.php.net to get a copy of this message
On Wed, 21 Mar 2001 06:10, Richard wrote: > Greetings. > > This is a part of my "reading one line" message... > > If one would need to remove one line in a flatfile, how would it be > done? I know there is no simple solution, and one is going to increment > through the chosen file.. But how is it done? My programming skills are > quite OK, but I am rather new to PHP and the for...loops doesnt work > exactly the same way as in C++, thus that I have forgotten the way to > read line in one file and in the same time iterate through another to > write... > > Remove one line? > > Thanks, > > - Richard One solution - read the entire file into an array with file() fopen() temp file to store output loop through array elements if not line to remove fwrite() current array element to open file endif end loop fclose() temp file Then you might copy the temp file over the original, or whatever else you want to do with the files. -- David Robley | WEBMASTER & Mail List Admin RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/ AusEinet | http://auseinet.flinders.edu.au/ Flinders University, ADELAIDE, SOUTH AUSTRALIA

« previous php.general (#44859) next »