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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]