Re: [PHP4BETA] re:Incremnting a number in a file

From: Date: Fri, 04 Feb 2000 06:36:18 +0000
Subject: Re: [PHP4BETA] re:Incremnting a number in a file
References: 1 2 3  Groups: php.version4 
Request: Send a blank email to php-version4+get-9787@lists.php.net to get a copy of this message
Joseph H Blythe wrote: > > Evan Klinger wrote: > > > The mode "w+" does indeed open the file for reading and writing; > > however, it truncates the file if it already exists and positions the > > stream at the beginning of the file. You would want to use mode "r+" > > which opens for reading and writing but does not truncate the file. > > Doh! I didn't even think of that he he, but this still does not do what I > intended I want to read the value 0 and increment it by one every time so it > would go 0, 1 , 2, 3 etc... not so it appends it to the end of the number, if > I use the w+ it still equals NULL? Before you write the new value (after you increment) you need to rewind() the file pointer so it points at the beginning of the file again and thus will write over the old value. I think this is what you're asking. -- ev ---------------------------- Evan Klinger evan@php.net AIM evan715

« previous php.version4 (#9787) next »